得到可爱的错误:
ERROR 2015-09-23 13:14:12,500 cgi.py:122] Traceback (most recent call last):
File "public/run.py", line 2, in <module>
from src import app
File "public/src/__init__.py", line 1, in <module>
from flask import Flask
ImportError: No module named flask
我已经使用 pip install -t lib -r requirements.txt
将 flask 安装到 public/lib
中。
public/appengine_config.py
from google.appengine.ext import vendor
# Add any libraries installed in the "lib" folder
vendor.add('lib')
# also does not work
# import os
# vendor.add(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib'))
public/app.yaml
version: 1
runtime: python27
api_version: 1
threadsafe: false
handlers:
- url: /static
static_dir: src/static
- url: /
script: run.py
public/run.py
from google.appengine.ext.webapp.util import run_wsgi_app
from src import app
run_wsgi_app(app)
public/src/__init__.py
from flask import Flask
# import settings
app = Flask('app')
# app.config.from_object('src.settings')
import views
看看 Starter Project .更重要的是,您应该更改 app.yaml
以指向 flask wsgi 应用程序。
- url: .*
script: src.app
run.py
脚本和 run_wsgi_app()
是运行应用程序的旧方法,不应使用。
我是一名优秀的程序员,十分优秀!