2017-03-17 75 views
3

我遇到了与我的Python App Engine Web应用程序的app.yaml设置有关的问题。不知怎的,除了我的应用程序中的index.html静态文件(javascript,CSS和HTML)其余部分没有部署到应用程序引擎。我在app.yaml的脚本下试过static_filesupload元素的各种组合。尽管它们中的一些适用于本地开发应用程序服务器,但通过gcloud app deploy在应用程序引擎上部署时,它们不起作用。由gcloud生成的日志不会显示任何错误。他们显示所有静态文件的“跳过[...]上传”等DEBUG消息。应用程序(它是一个AngularJS应用程序)的用于上传静态文件的app.yaml设置

目录结构如下:

<APP ROOT> 
├── app.yaml 
├── my_scripts 
│   ├── foo.py 
│   └── ... 
├── index.html 
├── mainapp.py 
└── web 
    ├── assets 
    │   ├── css 
    │   │   ├── bootstrap.min.css 
    │   │   ├── bootstrap-theme.min.css 
    │   │   ├── .... 
    │   │   └── .... 
    │   └── js 
    │    ├── app 
    │    │   ├── app.js 
    │    │   └── .... 
    │    └── lib 
    │     └── ... 
    └── partials 
     ├── login.html 
     └── ... 

以下是我的应用程序的app.yml文件。

runtime: python27 
api_version: 1 
threadsafe: true 

handlers: 

- url: /favicon\.ico 
    static_files: favicon.ico 
    upload: favicon\.ico 

- url: /(user|tasks)/.* 
    script: mainapp.app 

- url:/
    static_files: index.html 
    upload: index.html 

- url: /web 
    static_files: web\/[^\n]* 
    upload: web\/[^\n]* 

- url: /web 
    static_dir: web 

任何指针来帮助我解决这个问题将不胜感激。

+0

看看在http:// stackoverflow.com/questions/33447890/static-files-are-missing/33448239#33448239。查看解决该问题是否有助于在部署期间跳过静态文件。顺便说一句 - 有什么理由跳过它们显示在任何地方? –

回答

1

您已更改路由顺序。也就是说,/web应该紧跟在/处理程序之前,以便GAE路由将首先查找/web,然后它将转到/(请注意从顶部到底部的顺序)。如果您在/web之前定义/,则它始终显示index.html文件,因为/也将匹配/web

handlers: 

- url: /favicon\.ico 
    static_files: favicon.ico 
    upload: favicon\.ico 

- url: /(user|tasks)/.* 
    script: mainapp.app 

- url: /web 
    static_dir: web 

- url:/
    static_files: index.html 
    upload: index.html 

同时,我希望你没有添加^webskip_filesapp.yaml

+0

其实''/'不会匹配'/ web',你可能会想'/.*'或者只是'。*'? –

+0

正则表达式/应该返回一个匹配对象的字符串/网络 –

+0

我不知道锚是否自动添加.. –

1

以下处理程序配置为我工作:

- url: /(user|tasks)/.* 
    script: mainapp.app 

- url:/
    static_files: index.html 
    upload: index.html 

- url: /web 
    static_files: web/(.*)/(.*)/(.*)/(.*) 
    upload: web/(.*)/(.*)/(.*)/(.*) 

- url: /web 
    static_dir: web 
+0

所以你说这两个'/ web/assets/css/bootstrap.min.css'和'/ web/assets/js/app/app.js'都是用这个配置上传的? –

+0

是的。此代码正在开发GAE。 –

相关问题