34 lines
768 B
Python
34 lines
768 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
contacts = [] # In-memory storage
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/contact")
|
|
async def create_contact(
|
|
name: str = "John Doe",
|
|
email: str = "john@example.com",
|
|
message: str = "Hello there"
|
|
):
|
|
"""Demo contact endpoint"""
|
|
contact_id = len(contacts) + 1
|
|
|
|
contact = {
|
|
"id": contact_id,
|
|
"name": name,
|
|
"email": email,
|
|
"message": message,
|
|
"status": "received"
|
|
}
|
|
|
|
contacts.append(contact)
|
|
|
|
return {
|
|
"message": "Contact message received",
|
|
"contact_id": contact_id,
|
|
"status": "success",
|
|
"next_steps": [
|
|
"Your message is being reviewed",
|
|
"We will respond within 24 hours"
|
|
]
|
|
} |