📅  最后修改于: 2023-12-03 15:15:02.623000             🧑  作者: Mango
FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.7+ based on standard Python type hints. It was originally created by Sebastián Ramírez and is now developed and maintained by a growing community of contributors.
FastAPI allows you to easily build fast, highly efficient and scalable APIs with minimal boilerplate code. It is built on top of established web frameworks such as Starlette and Pydantic, and it leverages the outstanding performance of Python's asynchronous I/O framework, AsyncIO.
To get started with FastAPI, you'll need to install it first using pip:
!pip install fastapi
Create a new file called main.py
:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
Now, run the API server using:
uvicorn main:app --reload
FastAPI automatically generates an interactive documentation (similar to Swagger UI) that you can access by visiting http://localhost:8000/docs
. You can also try out your API using the 'Try it out' feature present in the documentation.
FastAPI is a powerful and performant web framework for building APIs with Python. If you're looking for a framework that is easy to use, scalable and efficient, FastAPI is a great choice. It's also well-documented and has a large community of developers working on it, which means you can get help when you need it. Give it a try and see how it can improve your API development workflow!
Data based on a survey of over 380 developers conducted by the FastAPI team in April 2020. Source: FastAPI - Python*