如何解决如何将从swaggerhub生成的flask swagger服务器部署到heroku?
我正在尝试部署从 swaggerhub 生成的 Flask 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()
解决方法
我自己找到了解决方案,将文件的主要内容更改如下:
FbaseAuth_SU.createUserWithEmailAndPassword(email,password).addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) { // send the user to the log - in screen.
reference.setValue(uHelper).addOnSuccessListener(new OnSuccessListener
@Override
public void onSuccess() {
Toast.makeText(Bio_SignUp.this,"Data Validated",Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(),Bio_LogIn.class));
finish();
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) { // an error when email and pass is wrong or invalid.
Toast.makeText(Bio_SignUp.this,e.getMessage(),Toast.LENGTH_LONG).show();
}
});
Procfile 中的内容:
#!/usr/bin/env python3
import connexion
from swagger_server import encoder
app = connexion.App(__name__,specification_dir='./swagger/')
app.app.json_encoder = encoder.JSONEncoder
app.add_api('swagger.yaml',arguments={'title': 'Docuware end point'},pythonic_params=True)
if __name__ == '__main__':
app.run()
requirements.txt 中的内容:
web: gunicorn swagger_server.__main__:app
这个解决方案适用于在heroku中部署,我删除了 main() 函数和没有函数方法的书面内容。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。