How to install fastapi in python

  1. Install Python in your local machine.

How to install Python in Window – BlogsHub

2. Create virtual environment

How to Setup Python virtual Environment on Windows – BlogsHub

3 Install fastapi using command prompt

ex: pip install fastapi[all]

or you can follow the below path for reference :

https://fastapi.tiangolo.com/tutorial/#advanced-user-guide

4. Use “pip freeze” command to check all dependencies (which is in lib folder)

5. Create main.py and Import fastAPI inside main.py and create instance

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
async def root():
    return {"Message" : "fastAPI first programme"}

6. Now start your webserver

syntex: uvicorn filename:instancename
ex: uvicorn main:app  or uvicorn main:app --reload

Leave a Reply

Your email address will not be published. Required fields are marked *