3
我使用Python 2.7在Google App Engine上運行Flask 0.9/Werkzeug 0.8.3,我迫切希望Werkzeug調試器運行。嘗試使用werkzeug_appengine_debugger後,我在控制檯以下異常:無法在Google App Engine上運行Flask調試模式
File "/path/to/application/main.py", line 14, in <module>
@app.route('/')
AttributeError: 'DebuggedApplication' object has no attribute 'route'
它不僅可以「路線」,但無論屬性瓶應用程序可以有。
我的文件樹是這個樣子,從flask-appengine-template借:
application
__init__.py
main.py
...
flask
flaskext
werkzeug
werkzeug_debugger_appengine
...
app.yaml
app.yaml中我針對WSGI應用:
application: application_name
version: 1
runtime: python27
api_version: 1
threadsafe: true
builtins:
- appstats: on
- admin_redirect: on
- deferred: on
- remote_api: on
libraries:
- name: jinja2
version: "2.6"
- name: markupsafe
version: "0.15"
inbound_services:
- warmup
handlers:
- url: .*
script: application.app
這裏是__init__.py
from flask import Flask
from werkzeug_debugger_appengine import get_debugged_app
## Starting app
app = Flask('application_name')
## Configuration
import os
import secrets
app.debug = True
app.secret_key = secrets.SECRET_KEY
app.csrf_session_key = secrets.CSRF_SESSION_KEY
# Auto-set debug mode based on App Engine dev environ
if 'SERVER_SOFTWARE' in os.environ and os.environ['SERVER_SOFTWARE'].startswith('Dev'):
app.debug = True
## Extensions
if app.debug:
app = get_debugged_app(app)
## Everything else
import main
如果沒有werkzeug_appengine_debugger,它也不起作用。以下初始化
app = DebuggedApplication(app, True)
仍會引發相同的異常。
在沒有GAE +燒瓶教程或文章我見過這個問題。爲什麼會發生?