【发布时间】:2019-02-13 22:19:03
【问题描述】:
我在根文件夹中的 main.py 文件如下所示。
app = Flask(__name__)
def configure_app(app):
app.config['SERVER_NAME'] = settings.FLASK_SERVER_NAME
app.config['SWAGGER_UI_DOC_EXPANSION'] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP
def initialize_app(app):
configure_app(app)
blueprint = Blueprint('api', __name__, url_prefix='/api')
api.init_app(blueprint)
api.namespaces.pop(0) #this is to remove default namespace from swagger doc
api.add_namespace(user_namespace)
app.register_blueprint(blueprint)
def main():
initialize_app(app)
app.run(debug=settings.FLASK_DEBUG)
if __name__ == "__main__":
main()
我的 app.yaml 文件如下所示。
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
python_version: 3
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
下面是 requirements.txt 文件。
Flask==1.0.2
flask-restplus==0.11.0
gunicorn==19.9.0
我在 flex 环境中运行 GAE。
我按照https://cloud.google.com/appengine/docs/flexible/python/quickstart 中的步骤操作,成功将应用部署到应用引擎。
当我转到 apppot 链接时,我收到 404 错误,并且 gcloud 日志尾部如下所示。
2018-09-09 01:49:00 default[20180909t113222] "GET /" 404
2018-09-09 01:49:01 default[20180909t113222] "GET /favicon.ico" 404
2018-09-09 01:49:09 default[20180909t113222] "GET /api/" 404
我尝试寻找解决方案,但从未找到与我的情况类似的解决方案。
非常感谢任何帮助。
谢谢。
【问题讨论】:
标签: python google-app-engine google-cloud-platform flask-restplus