@ryan.murray
To install FastAPI properly, follow these steps:
- Open your command line interface (e.g. Terminal on Mac, Command Prompt on Windows).
- Create a new virtual environment by running the following command:
Replace "myenv" with the name you want to give to your virtual environment.
- Activate the virtual environment by running the following command:
1
|
source myenv/bin/activate
|
- Install FastAPI using pip (which comes with Python) by running the following command:
- You may also want to install an ASGI server such as Uvicorn to run your FastAPI application. You can do this by running the following command:
- You can now create and run your FastAPI application. Create a Python file, for example, main.py, and add your FastAPI code.
- To run your FastAPI application using Uvicorn, run the following command:
1
|
uvicorn main:app --reload
|
Replace main
with the name of your Python file and app
with the name of your FastAPI application instance.
Your FastAPI application should now be up and running. You can access it by navigating to http://127.0.0.1:8000
in your web browser.