aboutsummaryrefslogtreecommitdiff
path: root/app/apis.py
blob: 69bf222a8af1e9e59d92d832c06c0c6fb4fe334f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from app import models
from api import app
from fastapi import Body, FastAPI, HTTPException
from fastapi.middleware.wsgi import WSGIMiddleware
from pydantic import BaseModel


@app.get("/version")
async def API_Version():
    return {"message": app.version}


@app.get("/v1/user-details")
async def API_User_Details(email: str):
    user = models.User.query.filter_by(email=email).first()
    try:
        assert user is not None
    except AssertionError:
        raise HTTPException(status_code=404, detail="User Not Found")
    return {"first_name": user.first_name, "last_name": user.last_name}