内容简介: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 静态文件服务配置及优化
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Facebook效应
[美] 大卫·柯克帕特里克 / 沈路、梁军、崔筝 / 华文出版社 / 2010-10 / 49.80
本书作者近距离地采访了与Facebook相关的人士,其中包括Facebook的创始人、员工、投资人、意向投资人以及合作伙伴,加起来超过了130人。这是真切详实的访谈,更是超级精彩的故事。作者以其细腻的笔触,精巧的叙事结构,解密了Facebook如何从哈佛的宿舍里萌发,创始人的内讧,权力之争,如何放弃华盛顿邮报的投资,怎样争取到第一个广告客户,而第一轮融资又如何获得一亿美元的估值,让人痴迷的图片产品......一起来看看 《Facebook效应》 这本书的介绍吧!