Serving html static in Google app engine Python

I'm having trouble loading static .html pages for my Python application. When I click a link, for example index.html, I get a blank page and log a 404 error on the server. This is the same for other static .html files such as about.html.

The application has a panel of static files. I tried looking in many places, but I seem to be unable to get .html pages. i.e.

INFO 2011-04-16 17: 26: 33,655 dev_appserver.py:3317] "GET / terms.html HTTP / 1.1" 404 -

YAML:

 application: quote version: 1 runtime: python api_version: 1 handlers: - url: /index\.html script: index.py - url: / script: index.py - url: /(.*\.(html)) static_files: static/\1 upload: static/HTML/(.*\.(html)) - url: /favicon.ico static_files: static/images/favicon.ico upload: images/favicon.ico mime_type: image/x-icon - url: /css static_dir: static/css - url: /images static_dir: static/images - url: /js static_dir: static/js 

My static files are in static / HTML and index.html is in the main folder.

I tried this too, but it doesn't seem to make any difference:

 - url: /favicon.ico static_files: static/images/favicon.ico upload: images/favicon.ico mime_type: image/x-icon - url: /css static_dir: static/css - url: /images static_dir: static/images - url: /js static_dir: static/js - url: /(.*\.(html)) static_files: static/\1 upload: static/HTML/(.*\.(html)) - url: /index\.html script: index.py - url: / script: index.py 
+6
source share
4 answers

Keep your HandlerScripts under the static directory processing part. IOW, just move it to the last.

 - url: /index\.html script: index.py - url: / script: index.py 
+4
source

Put /HTML in your static_files path:

 - url: /(.*\.(html)) static_files: static/HTML/\1 upload: static/HTML/(.*\.(html)) 
+2
source

You do not need to define each directory separately in your yaml file

 handlers: - url: /static static_dir: my_application/static 

Then in your corresponding html file, which you will display with django, you can call your static content, for example,

 <script src="/static/less_lib.min.js"></script> 
+1
source

You must correctly set aside your YAML.

On condition

script at the wrong level

 handlers: - url: /index\.html script: index.py 

json equivalent

 { "handlers": [ { "url": "/index\\.html" } ], "script": "index.py" } 

indentation

script at the right level

 handlers: - url: /index\.html script: index.py 

json equivalent

 { "handlers": [ { "url": "/index\\.html", "script": "index.py" } ] } 

YAML Online Parser

0
source

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


All Articles