2017-03-17 80 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。 –

相關問題