我目前正在使用angular-CLI生成的angular4投影来创建项目结构,我能够使用ng-serve提供服务并开发和查看更改。现在我想将它移植到我自己的后端托管,使用谷歌应用引擎和webApp2并使用dev_appserver.py app.yaml运行它。目前,我可以让它工作的唯一方法是进行ng-build并从dist文件夹中提供文件。我想这样做,所以我可以轻松地进行更改,但不必每次都等待重建。
答案 0 :(得分:1)
您可以在角度上使用环境,以便将python休息服务和其他环境指向生产。
示例:
<强> enviroment.ts 强>
export const environment = { production: false, urlServices: 'http://190.52.112.41:8075' };
<强> enviroment.prod.ts 强>
export const environment = { production: true, urlServices: 'http://localhost:8080' };
通过这种方式,你不需要编译来测试你的应用程序,因为angular总是会指向你的python应用程序。
答案 1 :(得分:0)
使用标准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
寻找有关我如何做得更好的任何反馈。