服务器的基础配置请看这篇:阿里云CentOS 7.6 配置Python生产环境( python3.7.6 + Nginx + virtualenv)
1.修改nginx.conf
2.在监听80端口的代码里面添加转发8080的虚拟路径
1.安装
pip install fastapi
pip install uvicorn
2.创建具有以下内容的文件 main.py
:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
3.运行项目:
uvicorn main:app --reload --host 0.0.0.0 --port 8080
这时候打开首页出现如图所示:
项目运行成功
文章来源互联网,如有侵权,请联系管理员删除。邮箱:417803890@qq.com / QQ:417803890
Python Free
邮箱:417803890@qq.com
QQ:417803890
皖ICP备19001818号
© 2019 copyright www.pythonf.cn - All rights reserved
微信扫一扫关注公众号:
Python Free