feat: initial Jimi Gallery prototype
- Public site (Home/Artists/Exhibitions/News/About/Contact) with EN/KO/JA i18n - Admin panel with login, CRUD, image upload, multilingual editing - Exhibition slider/lightbox view - FastAPI + MongoDB backend, JWT auth - Docker Compose deployment, behind nginx at jimi.yakenator.io
This commit is contained in:
24
backend/db.py
Normal file
24
backend/db.py
Normal file
@ -0,0 +1,24 @@
|
||||
"""Mongo connection and collection accessors."""
|
||||
import os
|
||||
|
||||
from motor.motor_asyncio import AsyncIOMotorClient
|
||||
|
||||
MONGO_URL = os.environ.get("MONGO_URL", "mongodb://localhost:27017")
|
||||
DB_NAME = os.environ.get("DB_NAME", "jimi_gallery")
|
||||
|
||||
client = AsyncIOMotorClient(MONGO_URL)
|
||||
db = client[DB_NAME]
|
||||
|
||||
artists = db.artists
|
||||
exhibitions = db.exhibitions
|
||||
news = db.news
|
||||
settings_col = db.settings # single-document collection keyed by _id="singleton"
|
||||
|
||||
|
||||
def strip_id(doc):
|
||||
"""Drop Mongo's _id before returning to the client."""
|
||||
if doc is None:
|
||||
return None
|
||||
doc = dict(doc)
|
||||
doc.pop("_id", None)
|
||||
return doc
|
||||
Reference in New Issue
Block a user