aj7tt / FastAPI

Building Microservice-APIs using fastAPI

Home Page:https://github.com/Aj7t/Microservice-APIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Microservice in Python using FastAPI

image

- #python #fastapi #restapi #microservices

FastAPI

Building API using fastapi

List of Microservice-APIs

1. MyIntro Api

https://rbhcz0ivuh.execute-api.ap-south-1.amazonaws.com/ajit/intro

2. movie API

source code
from fastapi import FastAPI
# from core.config import settings
from typing import Optional
from pydantic import BaseModel
from mangum import Mangum


class query(BaseModel):
    name: str
    age: Optional[int] = None
    profession: str
    interest: Optional[str] = None
    query: str



app = FastAPI()

@app.get("/")
async def welcome():
    return {"Greeting":"Hello World"}


@app.get("/intro")
async def my_intro():
    return {"Name":"Ajit kumar", "Age":21, "Country":"India", "Profession":"Software Engineer", "Languages":"Python, C++, C#", "Interests":"Football, Movies, Music", "Hobbies":"Coding, Reading, Travelling"}


@app.post("/query")
async def your_query(query: query):
    return {"Query":query.query, "Name":query.name, "Age":query.age, "Profession":query.profession}


handler = Mangum(app)