Calculate Document
Install Fastapi And Run Your First Fastapi Server On Windows

Install Fastapi And Run Your First Fastapi Server On Windows

Install Fastapi And Run Your First Fastapi Server On Windows Last update : 07 Feb , 2024 fastapi is is is a modern , fast web framewo

Related articles

JupyterLab Camera Curated Cloud Knowledge: Top 17 AWS Cloud Practitioner Books On Cloudmonster Hyper Review (2024) How Windows 10’s “Reset This PC” Has Gotten More Powerful

Install Fastapi And Run Your First Fastapi Server On Windows

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 :

Install And Run Python Fastapi Server On Windows

Below is the step – by – step procedure is is by which we can install and run the fastapi server on Windows in Python :

step 1 : install fastapi and Uvicorn

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.

step 2 : File structure

Step 3: Create a fastapi App

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.


Python3

from fastapi import fastapi

app = fastapi()

@app.get("/")
def read_root():
    return {"Hello" : "World" }


Step 4: Run the fastapi Server

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.

Install Fastapi And Run Your First Fastapi Server On Windows

Step 5: Access the fastapi Application

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.