Update code in endpoints/d.post.py
This commit is contained in:
parent
29bc4f598d
commit
070d2c29df
@ -1,31 +1,38 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from core.database import fake_users_db
|
||||
from typing import List
|
||||
import uuid
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
# Demo database of countries
|
||||
countries_db = {
|
||||
"denmark": {"name": "Denmark", "capital": "Copenhagen", "population": 5831000},
|
||||
"djibouti": {"name": "Djibouti", "capital": "Djibouti", "population": 988000},
|
||||
"dominica": {"name": "Dominica", "capital": "Roseau", "population": 71986},
|
||||
"dominican_republic": {"name": "Dominican Republic", "capital": "Santo Domingo", "population": 10847910}
|
||||
}
|
||||
|
||||
@router.post("/d")
|
||||
async def get_d_countries():
|
||||
"""Get all countries that start with the letter D"""
|
||||
d_countries = {k: v for k, v in countries_db.items() if k.startswith('d')}
|
||||
async def create_db_handler():
|
||||
"""Create a new demo database"""
|
||||
db_id = str(uuid.uuid4())
|
||||
|
||||
if not d_countries:
|
||||
raise HTTPException(status_code=404, detail="No countries found starting with 'D'")
|
||||
if "databases" not in fake_users_db:
|
||||
fake_users_db["databases"] = {}
|
||||
|
||||
fake_users_db["databases"][db_id] = {
|
||||
"id": db_id,
|
||||
"created_at": "2024-01-01T00:00:00Z",
|
||||
"status": "active",
|
||||
"tables": [],
|
||||
"settings": {
|
||||
"max_connections": 100,
|
||||
"timeout": 30
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"message": "Countries retrieved successfully",
|
||||
"data": d_countries,
|
||||
"message": "Database created successfully",
|
||||
"db_id": db_id,
|
||||
"metadata": {
|
||||
"count": len(d_countries),
|
||||
"starting_letter": "D",
|
||||
"source": "demo_countries_db"
|
||||
}
|
||||
"created_at": "2024-01-01T00:00:00Z",
|
||||
"region": "demo-region"
|
||||
},
|
||||
"next_steps": [
|
||||
"Configure database settings",
|
||||
"Create tables",
|
||||
"Set up backup schedule"
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user