【发布时间】:2021-07-18 12:01:34
【问题描述】:
我正在尝试部署从 swaggerhub 生成的烧瓶 swagger 服务器,下面是我的文件夹结构和我使用的 procfile。有谁知道在heroku中部署这个flask swagger服务器的方法吗?
project
│ swagger-codegen
│
└───swagger_server
│ │___controllers
| |___models
│ │___swagger
| |___test
│ __init__.py
| __main__.py
│ encoder.py
| util.py
|
│
|_ .dockerignore
|_ .gitignore
|_ dockerfile
|_ gitpush.sh
|_ Procfile
|_ requirements.txt
|_ runtime.txt
|_ setup.py
Procfile 中的内容:
web: gunicorn app:swagger_server
runtime.txt 中的内容:
python-3.7.8
Requirements.txt 中的内容:
connexion == 2.6.0
python_dateutil == 2.6.0
setuptools >= 21.0.0
gunicorn==20.0.0
main.py 文件中的内容:
#!/usr/bin/env python3
import connexion
import os
from swagger_server import encoder
def main():
app = connexion.App(__name__, specification_dir='./swagger/')
app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml', arguments={'title': 'end point'}, pythonic_params=True)
port = int(os.environ.get("PORT", 5000))
app.run(host = '0.0.0.0', port=port )
if __name__ == '__main__':
main()
【问题讨论】:
-
不确定这是否是问题所在,但您在端点后的参数字典中的主函数中有一个不匹配的 ':
arguments={'title': end point'} -
@YoavBenHaim 抱歉,输入问题时打错字
-
我认为应该是Procfile中的
main:swagger_server。 -
@charchit 试过了,又报错
-
你看过任何教程吗,这里有一篇同样的文章medium.com/@kar9475/…
标签: python flask heroku swagger swagger-codegen