Skip to content

Commit b8b9bbc

Browse files
committed
ready to send to storage
1 parent 30ad2d8 commit b8b9bbc

3 files changed

Lines changed: 54 additions & 113 deletions

File tree

‎app/main.py‎

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,22 @@
1-
from contextlib import asynccontextmanager
2-
3-
from fastapi import FastAPI, Request
4-
from fastapi.middleware.cors import CORSMiddleware
1+
from mosayic import app
2+
from fastapi.responses import HTMLResponse
53

64
from app.core.settings import get_settings
75
from app.services.logger import get_logger
8-
# from mosayic.core.firebase import initialize_firebase
96

107
logger = get_logger(__name__)
118
settings = get_settings()
12-
DEBUG_MODE = settings.debug_mode
13-
14-
15-
@asynccontextmanager
16-
async def lifespan(app: FastAPI):
17-
# initialize_firebase()
18-
logger.info("Application startup: Initializing services...")
19-
yield
20-
21-
22-
# Set up FastAPI app - docs will be disabled dynamically in production
23-
app = FastAPI(
24-
title="Mosaygent API",
25-
lifespan=lifespan,
26-
generate_unique_id_function=lambda route: route.name,
27-
docs_url=None if settings.environment == "production" else "/docs",
28-
redoc_url=None if settings.environment == "production" else "/redoc",
29-
)
30-
31-
32-
# TODO: Set explicit CORS origins
33-
app.add_middleware(
34-
CORSMiddleware,
35-
allow_origins=["*"],
36-
allow_credentials=True,
37-
allow_methods=["*"],
38-
allow_headers=["*"],
39-
)
409

4110

42-
@app.middleware("http")
43-
async def add_charset_to_json_response(request: Request, call_next):
11+
@app.get("/", response_class=HTMLResponse)
12+
async def root():
13+
html_content = """
14+
<html>
15+
<body>
16+
<h1>The Python API</h1>
17+
<p>This is the API root. If you're in the development environment, visit <a href="/docs">/docs</a> to see the available
18+
endpoints.</p>
19+
</body>
20+
</html>
4421
"""
45-
This middleware ensures that all JSON responses have the 'charset=utf-8'
46-
in their 'Content-Type' header. This is crucial for clients that do not
47-
default to UTF-8, preventing character encoding issues.
48-
"""
49-
response = await call_next(request)
50-
if "application/json" in response.headers.get(
51-
"content-type", ""
52-
) and "charset" not in response.headers.get("content-type", ""):
53-
response.headers["content-type"] = "application/json; charset=utf-8"
54-
return response
55-
56-
57-
# Include routers
58-
# app.include_router(caloratio_router, prefix="/caloratio", tags=["Caloratio"])
59-
60-
61-
@app.get("/")
62-
def read_root():
63-
return {
64-
"message": "Welcome to the Mosaygent API",
65-
"debug_mode": DEBUG_MODE,
66-
"environment": settings.environment
67-
}
68-
69-
70-
@app.get("/health")
71-
def health_check():
72-
return {
73-
"status": "healthy",
74-
"service": "mosaygent",
75-
"debug": DEBUG_MODE,
76-
"environment": settings.environment
77-
}
22+
return HTMLResponse(content=html_content, status_code=200)

‎pyproject.toml‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
2-
name = "mosaygent"
2+
name = "api"
33
version = "0.1.0"
4-
description = "Health and nutrition tracking API with AI-powered features"
4+
description = "API for the mobile app"
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
@@ -22,8 +22,4 @@ test = [
2222
]
2323

2424
[tool.pytest.ini_options]
25-
filterwarnings = [
26-
# Ignore known Supabase library deprecation warnings that will be fixed in a future release
27-
"ignore:The 'timeout' parameter is deprecated:DeprecationWarning",
28-
"ignore:The 'verify' parameter is deprecated:DeprecationWarning",
29-
]
25+
filterwarnings = []

‎uv.lock‎

Lines changed: 38 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)