内容简介:http://stackoverflow.com/questions/5609000/serve-static-file-using-app-engine
,我可以做什么来让App Engine提供index.html文件?
目前,我的app.yaml文件如下所示:
application: appname version: 1 runtime: python api_version: 1 handlers: - url: / static_dir: static_files
这应该做你所需要的:
https://gist.github.com/873098
说明:在App Engine Python中,可以使用正则表达式作为app.yaml中的URL处理程序,并将所有URL重定向到静态文件的层次结构.
示例app.yaml:
application: your-app-name-here version: 1 runtime: python api_version: 1 handlers: - url: /(.*\.css) mime_type: text/css static_files: static/\1 upload: static/(.*\.css) - url: /(.*\.html) mime_type: text/html static_files: static/\1 upload: static/(.*\.html) - url: /(.*\.js) mime_type: text/javascript static_files: static/\1 upload: static/(.*\.js) - url: /(.*\.txt) mime_type: text/plain static_files: static/\1 upload: static/(.*\.txt) - url: /(.*\.xml) mime_type: application/xml static_files: static/\1 upload: static/(.*\.xml) # image files - url: /(.*\.(bmp|gif|ico|jpeg|jpg|png)) static_files: static/\1 upload: static/(.*\.(bmp|gif|ico|jpeg|jpg|png)) # index files - url: /(.+)/ static_files: static/\1/index.html upload: static/(.+)/index.html # redirect to 'url + /index.html' url. - url: /(.+) static_files: static/redirector.html upload: static/redirector.html # site root - url: / static_files: static/index.html upload: static/index.html
为了处理不以识别类型(.html,.png等)结尾的网址的请求或/您需要将这些请求重定向到URL /,因此该目录的index.html已被提供.我不知道在app.yaml中有什么办法,所以我添加了一个javascript重定向器.这也可以用一个很小的 python 处理程序来完成.
redirector.html:
<!DOCTYPE html> <html lang="en"> <head> <script language="JavaScript"> self.location=self.location + "/"; </script> </head> <body> </body> </html>
http://stackoverflow.com/questions/5609000/serve-static-file-using-app-engine
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Go语言-打包静态文件
- webpack中如何加载静态文件
- Go Web 编程之 静态文件
- Nginx处理静态文件请求的配置问题
- 用 whitenoise 提供静态文件服务(Python)
- Nginx 静态文件服务配置及优化
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Ant Colony Optimization
Marco Dorigo、Thomas Stützle / A Bradford Book / 2004-6-4 / USD 45.00
The complex social behaviors of ants have been much studied by science, and computer scientists are now finding that these behavior patterns can provide models for solving difficult combinatorial opti......一起来看看 《Ant Colony Optimization》 这本书的介绍吧!