mirror of
http://88.130.71.182:3000/BlitTech/badoHair_be.git
synced 2026-06-12 23:23:22 +00:00
Initial Commit
This commit is contained in:
23
app/routers/contact.py
Normal file
23
app/routers/contact.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from pydantic import BaseModel, EmailStr
|
||||
from fastapi import APIRouter, Depends
|
||||
import asyncpg
|
||||
|
||||
from app.core.responses import ok
|
||||
from app.dependencies import get_db
|
||||
|
||||
router = APIRouter(prefix="/contact", tags=["Contact"])
|
||||
|
||||
|
||||
class ContactRequest(BaseModel):
|
||||
name: str
|
||||
email: EmailStr
|
||||
message: str
|
||||
|
||||
|
||||
@router.post("")
|
||||
async def submit_contact(body: ContactRequest, db: asyncpg.Connection = Depends(get_db)):
|
||||
await db.execute(
|
||||
"INSERT INTO contact_messages (name, email, message) VALUES ($1, $2, $3)",
|
||||
body.name, body.email, body.message,
|
||||
)
|
||||
return ok({"message": "Your message has been received. We will get back to you shortly."})
|
||||
Reference in New Issue
Block a user