futuredataengineer
futuredataengineer

Reputation: 462

Checking if my script for health check works

I wrote a simple script using FastAPI, main.py which is in C:\Users\me:

from fastapi import FastAPI

app = FastAPI()
@app.get("/health")
async def root():
       return {"message":"App is working"}

I created a virtual environment where I installed FastAPI and all the dependencies/packages around it. I activated the environment and simply ran main.py, but nothing happens, no error, no output. So it's just:

(myenv) (base) C:\Users\me>main.py

(myenv) (base) C:\Users\me>

It's probably a noob question and I'm new to this, but how do I know it works?

Upvotes: 0

Views: 731

Answers (1)

It works on my pc
It works on my pc

Reputation: 166

The official documentation (https://fastapi.tiangolo.com/tutorial/first-steps/) suggests that you should "pip install uvicorn" and run the following:

uvicorn main:app --reload

Upvotes: 1

Related Questions