Gotey
Gotey

Reputation: 629

FastAPI deploy in heroku giving an error h10

I am trying to deploy a trial fastAPI application on heroku:

from fastapi import FastAPI

app = FastAPI()

@app.get('/')

def get_root():
  return {'message': 'this is the root message'}

my root folder would look as:

venv/
main.py
Procfile
requierements.txt

inside main.py I have the code stated above, the Procfile contains;

web: uvicorn main:app --host=0.0.0.0 --port=${PORT:-5000}

and requierements.txt

fastapi

in the logs, when I access the root, I see;

2021-08-12T10:19:21.594055+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myappname.herokuapp.com request_id=7af272bc-7d23-41f3-a42e-afe380722f18 fwd="95.169.227.233" dyno= connect= service= status=503 bytes= protocol=https

Upvotes: 2

Views: 1220

Answers (1)

SADIK KUZU
SADIK KUZU

Reputation: 355

First you should rename requierements.txt (there is an extra 'e' in filename) to requirements.txt. Because "Heroku automatically recognizes your app as a Python app if it includes a requirements.txt, setup.py or Pipfile file in its root directory." (*)

And then you should add uvicorn into your requirements.txt.

Upvotes: 4

Related Questions