I am trying to marry this angular python project and this restful flask project.
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
Everything in the app/ folder is exactly the same from the python angular project.
If I comment out the following from app.yaml, I can access /rest/query and get the expected output.
- url: /(.+)
static_files: app/\1
upload: app/.*
- url: /
static_files: app/index.html
upload: app/index.html
However, when it is not commented out I get a 404 for /rest/query. At / I am able to see the static index.html page, loaded with the angular hooks. No data is populated since app.js cannot query /rest/query.
How can I set up a GAE Flask restful project that uses Angular?
app.yamlandmain.pyfiles?appengine_config .pyandvendor.py. These basically look towards a generated/libfolder in the directory root for dependencies.