我正在尝试将这个angular python 项目和这个restful flask 项目结合起来。
Directory
- /app
- css/app.css
- js/app.js
- index.html
- app.yaml
- main.py
- appengine_config.py
- vendor.py
- requirements.txt
app.yaml
application: your-application-id-here
version: 1
runtime: python37
api_version: 1
threadsafe: yes
handlers:
- url: /rest/.*
script: main.APP
- url: /(.+)
static_files: app/\1
upload: app/.*
- url: /
static_files: app/index.html
upload: app/index.html
main.py
from flask import Flask
from flask.ext import restful
APP = Flask(__name__)
api = restful.Api(APP)
class HelloWorld(restful.Resource):
def get(self):
return {'hello': 'world'}
api.add_resource(HelloWorld, '/rest/query/')
@app.errorhandler(404)
def page_not_found(e):
"""Return a custom 404 error."""
return 'Sorry, Nothing at this URL.', 404
@app.errorhandler(500)
def page_not_found(e):
"""Return a custom 500 error."""
return 'Sorry, unexpected error: {}'.format(e), 500
该文件夹中的所有内容都app/与 python angular 项目完全相同。
如果我从 中注释掉以下内容app.yaml,我可以访问/rest/query并获得预期的输出。
- url: /(.+)
static_files: app/\1
upload: app/.*
- url: /
static_files: app/index.html
upload: app/index.html
但是,当它没有被注释掉时,我得到一个404for /rest/query。在/我能够看到index.html加载有角钩的静态页面。app.js由于无法查询,因此未填充数据/rest/query。
如何设置使用 Angular 的 GAE Flask 宁静项目?