본문 바로가기

개발하자

Fast API가 오류 로드를 계속 발생시킵니다(ASGI 앱).

반응형

Fast API가 오류 로드를 계속 발생시킵니다(ASGI 앱).

파일 이름은 내가 실행할 때마다 코드 아래에 오류가 나타난다.

from fastapi import FastAPI  app = FastAPI()   @app.get("/") async def root():     return {"message": "Hello World"} 

오류

INFO:     Will watch for changes in these directories: ['/Users/Documents/main.py'] INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO:     Started reloader process [58745] using statreload ERROR:    Error loading ASGI app. Could not import module "main". 

main.py 파일과 동일한 디렉터리에서 uvicorn main:app --packet 명령을 실행하고 있습니까? 아마 그게 네 문제일 거야. 나는 당신의 코드를 테스트했고 그것은 나에게 효과가 있다.


파일 이름이 메인인지 확인하거나 이름이 'main'이면 uvicorn 예:app --filename이라고 써야 합니다.

 

반응형