我正在尝试创建登录和个人资料页面。这是app.yaml文件,适用于' /'和' /(任何)'。而不是' /(任何)'我希望路径为' / user /.*'。我尝试了很多,但它只渲染了页面的html部分。如何配置我的app.yaml,以便它使用完整的CSS和JS呈现并适用于' /(任何)/(任何)'?
application: My-App-name
version: 1
runtime: python27
api_version: 1
threadsafe: yes
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)
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
# site root
- url: /.*
script: main.app
#- url: /user/.*
# script: main.app
libraries:
- name: jinja2
version: latest
PS:我的文件夹树为
的app.yaml
static-> CSS,JS,图片,html文件
index.yaml中 main.app
答案 0 :(得分:1)
尝试类似:
- url: /(.+)/(.*\.js)
mime_type: text/javascript
static_files: static/\2
upload: static/(.*\.js)
这将匹配/anything/file.js
以及/anything/anything/file.js
以及/junk/static/hellothere/this/matches/everything/file.js
,因为(。+)也匹配所有斜杠。如果你不希望它匹配两者,那么你需要处理正则表达式中的斜杠(单独处理字符和斜杠):
- url: /([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)/(.*\.js)
mime_type: text/javascript
static_files: static/\3
upload: static/(.*\.js)
匹配/any-thing/any_th-ing/file.js
。如果您想更具体,可以使用:
- url: /user/([A-Za-z0-9-_]+)/(.*\.js)
mime_type: text/javascript
static_files: static/\2
upload: static/(.*\.js)
匹配`/user/anything/file.js'或:
- url: /([A-Za-z0-9-_]+)/static/(.*\.js)
mime_type: text/javascript
static_files: static/\2
upload: static/(.*\.js)
匹配/anything/static/file.js