Define routes using APIRouter
This commit is contained in:
parent
abd0f45c91
commit
de1d79ff9f
|
@ -1,5 +1,5 @@
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
from app.routes import router
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
app.include_router(router)
|
||||||
from app import routes, schemas
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
from fastapi import HTTPException, Response, status
|
from fastapi import APIRouter, HTTPException, Response
|
||||||
|
|
||||||
from app import app
|
|
||||||
from app.schemas import *
|
from app.schemas import *
|
||||||
from app.twilio import send_otp
|
from app.twilio import send_otp
|
||||||
from database.crud import insert_data, verify_otp
|
from database.crud import insert_data, verify_otp
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
@app.post("/register")
|
|
||||||
|
@router.post("/register")
|
||||||
async def create_user(request: RegisterSchema):
|
async def create_user(request: RegisterSchema):
|
||||||
insert_data(schema="Users", data=request)
|
insert_data(schema="Users", data=request)
|
||||||
send_otp(receiver=request.mobile)
|
send_otp(receiver=request.mobile)
|
||||||
|
@ -14,14 +15,14 @@ async def create_user(request: RegisterSchema):
|
||||||
|
|
||||||
|
|
||||||
# FIXME Use OAuth2 for verification
|
# FIXME Use OAuth2 for verification
|
||||||
@app.post("/login")
|
@router.post("/login")
|
||||||
async def log_in(request: LoginSchema, response: Response):
|
async def log_in(request: LoginSchema, response: Response):
|
||||||
return {"message": "Logged in successfully"}
|
return {"message": "Logged in successfully"}
|
||||||
# response.status_code = status.HTTP_400_BAD_REQUEST
|
# response.status_code = status.HTTP_400_BAD_REQUEST
|
||||||
# return {"message": "The email/password combination is not correct"}
|
# return {"message": "The email/password combination is not correct"}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/otpVerification")
|
@router.post("/otpVerification")
|
||||||
async def validate_otp(request: OTPSchema, response: Response):
|
async def validate_otp(request: OTPSchema, response: Response):
|
||||||
if verify_otp(data=request):
|
if verify_otp(data=request):
|
||||||
return {"message": "The OTP has been verified successfully"}
|
return {"message": "The OTP has been verified successfully"}
|
||||||
|
|
Loading…
Reference in New Issue