簡體   English   中英

Google App Engine上的Angular4和WebApp2

[英]Angular4 and WebApp2 on google App engine

我目前正在使用由angular-CLI生成的angular4投影來創建項目結構,並且能夠使用ng-serv為其提供服務並開發並查看更改。 現在,我想將其移動到使用Google App Engine和webApp2托管在我自己的后端上,並使用dev_appserver.py app.yaml運行它。 目前,使它起作用的唯一方法是執行ng-build並將文件從dist文件夾中提供。 我想這樣做,這樣我就可以輕松進行更改,而不必每次都等待它重建。

您可以在angular上使用環境,以便為您提供python rest服務和另一個生產環境。

例:

環境

export const environment = {
  production: false,
  urlServices: 'http://190.52.112.41:8075'
};

環境產品

export const environment = {
  production: true,
  urlServices: 'http://localhost:8080'
};

這樣,您就不需要編譯來測試您的應用程序,因為angular始終會指向您的python應用程序。

使用標准App Engine配置的app.yaml解決方案:

service: stage
runtime: python27
api_version: 1
threadsafe: true

skip_files:
- ^(?!dist)  # Skip any files not in the dist folder

handlers:
# Routing for bundles to serve directly
- url: /((?:inline|main|polyfills|styles|vendor)\.[a-z0-9]+\.bundle\.js)
  secure: always
  redirect_http_response_code: 301
  static_files: dist/\1
  upload: dist/.*

# Routing for a prod styles.bundle.css to serve directly
- url: /(styles\.[a-z0-9]+\.bundle\.css)
  secure: always
  redirect_http_response_code: 301
  static_files: dist/\1
  upload: dist/.*

# Routing for typedoc, assets and favicon.ico to serve directly
- url: /((?:assets|docs)/.*|favicon\.ico)
  secure: always
  redirect_http_response_code: 301
  static_files: dist/\1
  upload: dist/.*

# Any other requests are routed to index.html for angular to handle so we don't need hash URLs
- url: /.*
  secure: always
  redirect_http_response_code: 301
  static_files: dist/index.html
  upload: dist/index\.html
  http_headers:
    Strict-Transport-Security: max-age=31536000; includeSubDomains
    X-Frame-Options: DENY

尋找任何有關如何更好地做到這一點的反饋。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM