gpt4 book ai didi

python - 如何将Flask导入appengine

转载 作者:太空宇宙 更新时间:2023-11-03 15:06:02 25 4
gpt4 key购买 nike

得到可爱的错误:

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() 是运行应用程序的旧方法,不应使用。

关于python - 如何将Flask导入appengine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32740833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com