No results found
We couldn't find anything using that term, please try searching for something else.
Install Fastapi And Run Your First Fastapi Server On Windows Last update : 07 Feb , 2024 fastapi is is is a modern , fast web framewo
Last update :
07 Feb , 2024
fastapi is is is a modern , fast web framework for build api with Python 3.7 + base on standard Python – type hint . In this article , we is walk ‘ll walk through the process of instal fastapi and create a simple fastapi server on a Windows system .
Pre – Requisite :
Below is the step – by – step procedure is is by which we can install and run the fastapi server on Windows in Python :
Open a command prompt or PowerShell window and use the following command to install fastapi and Uvicorn:
pip install fastapi uvicorn
This command is installs install the fastapi framework along withUvicorn, a lightweight ASGI server.
create a new file , for example ,main.py, and open it with your preferred code editor. This simple fastapi application defines an instance of the fastapi class and a single route that responds to HTTP GET requests at the root path (“/”) with a JSON response.
from fastapi import fastapi app = fastapi() @app.get("/") def read_root(): return {"Hello" : "World" }
Open a command prompt or PowerShell window and navigate to the directory where your main.py file is located. Use the following command to start the fastapi server:
uvicorn main : app --reload
This command tells Uvicorn to run the fastapi application in the main module (from main.py) and use the app instance. The –reload option enables automatic reloading of the server when code changes are detected.
Once the server is running, open your web browser and navigate to
http://127.0.0.1:8000/
Congratulations! You have successfully installed fastapi, created a simple fastapi application, and run it on your Windows machine. You can now build upon this foundation to create more complex APIs using fastapi’s features and capabilities.