Вызов функции JavaScript из файла .js в Google App Engine - PullRequest
1 голос
/ 05 декабря 2011

Я пытался вызвать функцию из файла .js в среде Google App Engine.

код html-печати выглядит следующим образом:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class jumpPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'
        self.response.out.write('');
        self.response.out.write('');
        self.response.out.write('<head>');
        self.response.out.write('<script type="text/javascript" src="/js/pxc11.js" >');
        self.response.out.write('</script>');
        self.response.out.write('</head>');
        self.response.out.write('<body">');
        self.response.out.write('<form name="f1">');
        self.response.out.write('  <input type="hidden" name="theStartValue" value="1"><p>');
        self.response.out.write('  <input type="button" value="-15" onClick="dummy()">');
        self.response.out.write('  <input type="button" value="+15" onClick="dummy()" ><p>');
        self.response.out.write('</form>');
        self.response.out.write('</body>');
        self.response.out.write('');
        self.response.out.write('</html>');


application = webapp.WSGIApplication(
                                     [('/tonteria', jumpPage)],
                                     debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

, а затемПросто .js:

<script language="javascript" type="text⁄javascript">
function dummy()
{
    alert("POPOPOPOPOPO");
}
<⁄script>

В app.yaml есть статическая папка с файлом .js.

    handlers:
    - url: /js
      static_dir: js
    - url: /tonteria
      script: tonteria.py

Ответы [ 2 ]

4 голосов
/ 05 декабря 2011

.js файлы содержат Javascript , а не теги HTML.

0 голосов
/ 05 декабря 2011

Ваша жизнь может быть проще, если превратить файл в шаблон HTML, а затем отобразить его с вашими переменными.У Google есть отличный учебник

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...