【发布时间】:2021-11-13 07:40:17
【问题描述】:
我安装了 FASTAPI 并在下面提到的代码中运行
'
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"Hello": "World"}
' 并且在执行文件时在控制台中遇到以下提到的错误 '
(venv) D:\FASTAPI>uvicorn main:app --reload
INFO: Will watch for changes in these directories: ['D:\\FASTAPI']
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: Started reloader process [7900] using watchgod
ERROR: Error loading ASGI app. Attribute "app" not found in module "main".
' 我非常感谢任何建议或建议
【问题讨论】:
-
你在什么文件中保存了python代码?是否存放在
d:\FASTAPI目录下? -
问题是你的python解释器的地址。