A web framework for building APIs quickly and efficiently.
FastApi is a lightweight framework designed to help developers build robust and scalable APIs with minimal effort. It supports asynchronous programming and automatic API documentation.
To get started, install the framework using pip:
pip install fastapiYou'll also need an ASGI server like uvicorn:
pip install uvicornTo run the app, navigate to the project directory and execute:
uvicorn main:app --reloadReplace main with the name of your main application file.
Here's a simple example to get you started:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}This creates a basic API with a single endpoint that returns a JSON response. You can access it by visiting http://localhost:8000 in your web browser.