📅  最后修改于: 2023-12-03 15:00:44.216000             🧑  作者: Mango
FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.6+ based on standard Python type hints. It was created to be easy to use, fast to develop with, and provide high-performance.
To get started with FastAPI, you'll first need to install it using pip:
pip install fastapi
You'll also need to install a web server to run FastAPI. For development purposes, we recommend using uvicorn
:
pip install uvicorn
Once you've installed FastAPI and uvicorn
, you're ready to start building your API. Here's a simple example:
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
async def root():
return {'message': 'Hello, FastAPI!'}
FastAPI comes with automatic interactive documentation. To access the documentation, visit http://localhost:8000/docs
in your web browser. This documentation provides a user interface for testing your API, as well as detailed documentation for each endpoint.
FastAPI is a powerful and easy-to-use web framework for building APIs with Python. With automatic documentation, robust architecture enforcement, and high performance, it's a great choice for anyone looking to build APIs quickly and reliably.