我正在使用flask和python 2.7 GAE SDK。我想在我的应用程序中包含一个交互式shell。
我想在我的应用程序中包含以下交互式python shell,以便我可以在开发时与GAE API进行交互 - http://code.google.com/p/google-app-engine-samples/source/browse/trunk/shell/
按照说明我已经将static /和templates /文件夹和shell.py复制到我的应用程序的根目录。
我还将url路由仅添加到我的app.yaml(shell) -
application: myflaskonappengineapp
version: 1
runtime: python27
api_version: 1
threadsafe: false
default_expiration: "5d"
builtins:
- appstats: on
- admin_redirect: on
- deferred: on
- remote_api: on
libraries:
- name: jinja2
version: "2.6"
- name: markupsafe
version: "0.15"
- name: lxml
version: "2.3"
- name: numpy
version: "1.6.1"
- name: PIL
version: "1.1.7"
- name: pycrypto
version: "2.3"
- name: setuptools
version: "0.6c11"
- name: webapp2
version: "2.3"
- name: webob
version: "1.1.1"
- name: yaml
version: "3.10"
inbound_services:
- warmup
handlers:
- url: /favicon.ico
static_files: application/static/img/favicon.ico
upload: application/static/img/favicon.ico
- url: /robots.txt
static_files: application/static/robots.txt
upload: application/static/robots.txt
- url: /_gae_mini_profiler/static
static_dir: packages/flaskext/gae_mini_profiler/static
- url: /static
static_dir: application/static
#interactive shell
- url: /shell
script: shell.py
- url: /remote_api
script: /opt/google_appengine/google/appengine/ext/remote_api/handler.py
- url: .*
script: application.app
但是当我尝试访问url / shell时,出现404错误?我是否还需要配置烧瓶以进行布线?为什么烧瓶处理这个网址而不是shell.py?
答案 0 :(得分:4)
您需要修改shell.py以处理URL'/ shell'以及app.yaml。 特别是,您需要修改the line 303 of the shell.py。
这
[('/', FrontPageHandler),
到
[('/shell', FrontPageHandler),
您还需要更新您的app.yaml(添加通配符):
- url: /shell.*
script: shell.py
请考虑在shell处理程序中添加login:admin,否则您将向世界上的每个人开放shell功能。