我试图将这个angular python项目和这个restful flask项目结合起来。
然而,如果没有将其注释掉,我会在
目录
- /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
然而,如果没有将其注释掉,我会在
/rest/query
处得到一个404
错误。在/
处,我能够看到静态的index.html
页面,已经加载了angular钩子。由于app.js
无法查询/rest/query
,因此没有数据被填充。
我应该如何设置一个使用Angular的GAE Flask Restful项目?
app.yaml
和main.py
文件的位置吗? - Dan Cornilescuappengine_config .py
和vendor.py
。它们基本上是在目录根目录下寻找生成的/lib
文件夹中的依赖项。 - user1222324562