This is a basic FastAPI application that responds with "Hello, World!" at the root URL.
Run python -m venv venv
to create a virtual environment named venv.
Windows: venv\Scripts\activate
macOS/Linux: source venv/bin/activate
To run this application, you need Python 3.7+ and FastAPI. You can install FastAPI with the following command:
pip install fastapi[all]
To run the application, you will need an ASGI server; uvicorn
is recommended. Install it using:
pip install uvicorn
After installation, you can start the server with:
uvicorn main:app --reload
The --reload
option makes the server restart after code changes, which is useful during development.
Once the server is running, visit http://127.0.0.1:8000/
in your web browser. You should see the message "Hello, World!" displayed in JSON format.