JCPedroza / back-end-hello-world-py-fastapi

Back-end "hello world" program written in Python using the FastAPI framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python Back-End Hello World: FastAPI

Write a Python program that listens to localhost:8000 and responds with the json { "hello": "world" } to a get request directed at the root endpoint located at /.

Install needed packages

pip install fastapi uvicorn

Start server and run app

uvicorn main:app

Send get request to root

http localhost:8000 # using httpie in debian

Should return header and body similar to:

HTTP/1.1 200 OK
content-length: 17
content-type: application/json
date: Fri, 14 Feb 2024 05:29:06 GMT
server: uvicorn

{
    "hello": "world"
}

About

Back-end "hello world" program written in Python using the FastAPI framework.

License:MIT License


Languages

Language:Python 100.0%