Fast API

  create the folder. Any place on your computer..

that folder opens with vs code.

on vs code open the terminal...

type below command

py -m venv vbox

vbox means virtual box .. you can create other names as your wish according your project

it's crate the virtual box...

once create the vbox.. activate the vbox through the below cmd...

./scripts/activate..

now it's activated and shows like (vbox)

once it's you create the vbox enter below cmd

pip install fastapi[standard]

it's install fastapi and all tools

once it's done.. you have to enter below cmd.. so that your project safe and sucure for runing..

pip freeze > requirements.txt 

after that you have to create the main.py and enter the below code

from fastapi import FastAPI

app = FastAPI()

@app.get ('/')
def index():
    return {'story':'king'}

once it's done we have to run server on below cmd

fastapi dev 

it's starting the server

One of the most exciting features of FastAPI is its automatic documentation. When you run your FastAPI application, two documentation interfaces are automatically generated: Swagger UI and Redoc.

You can access these at http://127.0.0.1:8000/docs for Swagger UI 

and http://127.0.0.1:8000/redoc for Redoc

if you wish..you can change the path also defalt is 8000.. 

for that you have to enter like this.. fastapi dev --port 1223

now it's sharting for this port  http://127.0.0.1:1223

f






0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post