【发布时间】:2021-07-11 04:14:22
【问题描述】:
我正在尝试将 Uvicorn localhost 配置为一个 url,而不是看起来像 http://0.0.0.0:8000 到 http://dev.app。如果您能指出正确的方向,那就太好了。谢谢
【问题讨论】:
我正在尝试将 Uvicorn localhost 配置为一个 url,而不是看起来像 http://0.0.0.0:8000 到 http://dev.app。如果您能指出正确的方向,那就太好了。谢谢
【问题讨论】:
在 Windows 中编辑 C:/Windows/System32/drivers/etc/hosts 或在 Linux 中编辑 /etc/hosts:
127.0.0.1 dev.app
将服务器端口更改为 80:
import uvicorn
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def root():
a = "a"
b = "b" + a
return {"hello world": b}
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=80)
【讨论】: