Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

515
Visualizações
How to deploy flask swagger server generated from swaggerhub to heroku?

I am trying to deploy the flask swagger server generated from swaggerhub, below is my folder structure and procfile i use. Does any one knows the way to deploy this flask swagger server in heroku?

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


content in Procfile:

web: gunicorn app:swagger_server

content in runtime.txt:

python-3.7.8

content in Requirments.txt:

connexion == 2.6.0
python_dateutil == 2.6.0
setuptools >= 21.0.0
gunicorn==20.0.0

content in main.py file:

#!/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()

Error on the heroku log : enter image description here

Error on the heroku web log: enter image description here

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I found the solution myself which you can use it to deploy in appengine too, change the main content of the file as below :

#!/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()

content in the Procfile:

web: gunicorn swagger_server.__main__:app

content in requirements.txt :

connexion == 2.6.0
python_dateutil == 2.6.0
setuptools >= 21.0.0
gunicorn

this solution works for deploying in heroku, I removed the main() function and written contents without a function approach.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda