from fastapi import FastAPI, status, HTTPException from pydantic import BaseModel from typing import Optional, List from database import SessionLocal import models class User(BaseModel): id:int name:str email:str password:str class Config: orm_mode = True db=SessionLocal() app=FastAPI() @app.get("/hello") async def hi(): return {"hello my dear"} @app.post("/create_user",response_model=User) async def create_user(request:User): opj = models.User( id=request.id, name=request.name, email=request.email, password=request.password, ) db.add(opj) db.commit() return opj
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)