c4sh
c4sh

Reputation: 701

Calling a JavaScript function from a .js file in Google App Engine

I was trying to call a function from a .js file in the Google App Engine enviroment.

the code of the html print goes like this:

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()

and then the .js is just this:

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

The app.yaml includes a static folder that has the .js file.

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

Upvotes: 1

Views: 708

Answers (2)

mcotton
mcotton

Reputation: 844

Your life might be easier by making the file into an html template and then rendering it with your variables. Google has a great tutorial

Upvotes: 0

SLaks
SLaks

Reputation: 888167

.js files contain Javascript, not HTML tags.

Upvotes: 4

Related Questions