Download JavaScript in the Google App Engine

I am so confused by loading JavaScript in the Google App Engine . I am using a Django template.

Firstly, in my base HTML file, I cannot load the downloaded jQuery code from a local user, d:/jquery.js , for example

 <script src="d:\jquery.js" type="text/javascript" ></script></head>, 

This line is in my base HTML file. It works when I load jQuery from remote . how

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"type="text/javascript" ></script></head> 

I do not know why.

Secondly, I cannot load my own JavaScript code into my HTML file. Let's say I create a JavaScript file, such as layout.js , and I try to load it like this in my child HTML file, which, incidentally, is inherited from base HTML.

  <body><script src="layout.js" type="text/javascript"></script></body> 

And that doesn't work at all. The only way this works, I tried when I put the actual JavaScript code in the body of my base HTML file. how

 <body><script> $(document).ready( $("#yes").click(function() { $("#no").hide("slow"); })); </script> 

I do not know why ... How to fix this?

+4
source share
1 answer

AppEngine knows nothing about paths in your local system; it will only upload files that you configured it to. Do this by specifying the following line in the app.yaml file:

 handlers: - url: /js static_dir: js 

In this case, /js is a subdirectory of your main project directory, and you can put all your static JavaScript files there. They will be uploaded to the production server, and you can include them in your HTML with:

 <script src="/js/jquery.js" type="text/javascript" ></script> 
+17
source

Source: https://habr.com/ru/post/1343446/


All Articles