Im stuck since a week and I allready looked in a million spanish and english forums...
The thing is that Javascript does not work on my localhost when I launch my website from Google App Engine.
If I copy/paste all the html, css and .js files and then I launch in the browser from Notepad++ works perfectly, but for any reason does not work on GAE, and I don´t know why.
The app.yaml works because if I write in the browser:
http://localhost:8080/js/script.js
, then appear the javascript code.
Here is all my code:
HTML:
<script type="text/javascript" src="/js/jquery.js"</script>
<script type="text/javascript" src="/js/script.js"></script>
JS:
$(document).ready(function() {
$("#ingles").fadeOut(1000);
});
My app.yaml:
application: juanmamorenoportfolio
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /stylesheets
static_dir: stylesheets
- url: /images
static_dir: static_files/images
- url: /js
static_dir: js
- url: .*
upload: templates/index.html
static_files: templates/index.html
libraries:
- name: webapp2
version: latest
- name: jinja2
version: latest
and my main.py (I suspect the problem should be here):
import os
import webapp2
import jinja2
jinja_environment = jinja2.Environment(autoescape=True,
loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))
class MainHandler(webapp2.RequestHandler):
def get(self):
template = jinja_environment.get_template('index.html')
self.response.out.write(template.render())
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
Many thanks!!
Javascript works perfectly on SDK and production.
upload:
is required in - url:
. http://localhost:8080/js/script.js
to check if code is shown. Read documentation Static file handlers .
是的,它与上upload:
thing: 静态文件模式处理程序
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.