initial, step 2 already
This commit is contained in:
47
apps/ui/main.py
Normal file
47
apps/ui/main.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""UI main entry point."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
# Initialize FastAPI app
|
||||
app = FastAPI(
|
||||
title="Home Automation UI",
|
||||
description="User interface for home automation system",
|
||||
version="0.1.0"
|
||||
)
|
||||
|
||||
# Setup Jinja2 templates
|
||||
templates_dir = Path(__file__).parent / "templates"
|
||||
templates = Jinja2Templates(directory=str(templates_dir))
|
||||
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def index(request: Request) -> HTMLResponse:
|
||||
"""Render the main UI page.
|
||||
|
||||
Args:
|
||||
request: The FastAPI request object
|
||||
|
||||
Returns:
|
||||
HTMLResponse: Rendered HTML template
|
||||
"""
|
||||
return templates.TemplateResponse("index.html", {"request": request})
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Run the UI application with uvicorn."""
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run(
|
||||
"apps.ui.main:app",
|
||||
host="0.0.0.0",
|
||||
port=8002,
|
||||
reload=True
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user