(agentlearning) PS D:\code\PythonProject> fastapi dev fast_api.py --port 8001 #规定端口号
FastAPI Starting development server 🚀 Searching for package file structure from directories with __init__.py files Importing from D:\code\PythonProject module 🐍 fast_api.py code Importing the FastAPI app object from the module with the following code: from fast_api import app app Using import string: fast_api:app server Server started at http://127.0.0.1:8001 server Documentation at http://127.0.0.1:8001/docs tip Running in development mode, for production use: fastapi run Logs: INFO Will watch for changes in these directories: ['D:\\code\\PythonProject'] INFO Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit) INFO Started reloader process [2252] using WatchFiles INFO Started server process [6800] INFO Waiting for application startup. INFO Application startup complete. INFO 127.0.0.1:51683 - "GET / HTTP/1.1" 200 INFO 127.0.0.1:51683 - "GET /docs HTTP/1.1" 200 INFO 127.0.0.1:51683 - "GET /openapi.json HTTP/1.1" 200 INFO 127.0.0.1:53840 - "GET / HTTP/1.1" 200
指定app位置的不同方式
命令行直接指定
1 2
fastapi dev fast_api.py fastapi dev --entrypoint fast_api:app