一: 下载安装包
1: pip install fastapi
2: pip install uvicorn
二:基本操作
from fastapi import FastAPI import uvicorn #实例对象 app =FastAPI() #默认界面 @app.get("/") async def main(): return { "message":"Hello World,Fastapi" } if __name__ == '__main__': import uvicorn uvicorn.run(app,host ='0.0.0.0',port =8000 )
直接运行即可