File size: 1,375 Bytes
ab3b796
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates

app = FastAPI()

# Mount static files
app.mount("/static", StaticFiles(directory="static"), name="static")

# Setup templates
templates = Jinja2Templates(directory="templates")

@app.get("/", response_class=HTMLResponse)
async def home(request: Request):
    return templates.TemplateResponse(
        "index.html", 
        {
            "request": request,
            "app_name": "MegicAI Test",
            "user_credits": 100,
            "tools": [
                {
                    "id": "text_gen",
                    "name": "Text Generator",
                    "description": "Generate creative text",
                    "icon": "fas fa-font",
                    "category": "text",
                    "credits": 5
                },
                {
                    "id": "image_gen",
                    "name": "Image Creator",
                    "description": "Create images from text",
                    "icon": "fas fa-image",
                    "category": "image",
                    "credits": 10
                }
            ]
        }
    )

@app.get("/hello")
def read_root():
    return {"message": "Hello World"}