Spaces:
Paused
Paused
Update telegram_preview.py
Browse files- telegram_preview.py +13 -1
telegram_preview.py
CHANGED
|
@@ -17,12 +17,24 @@ from typing import Optional
|
|
| 17 |
from fastapi import APIRouter, Response, Request
|
| 18 |
from fastapi.responses import HTMLResponse, StreamingResponse
|
| 19 |
from fastapi.templating import Jinja2Templates
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# βββ Locate templates folder absolute path ββββββββββββββββββββββββββββββββββββ
|
| 22 |
BASE_DIR = Path(__file__).resolve().parent
|
| 23 |
templates = Jinja2Templates(directory=str(BASE_DIR / "templates"))
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# βββ Environment βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 27 |
TOKEN = os.getenv("BOT_TOKEN")
|
| 28 |
FALLBACK_IMG = "https://telegram.org/img/t_logo.png"
|
|
|
|
| 17 |
from fastapi import APIRouter, Response, Request
|
| 18 |
from fastapi.responses import HTMLResponse, StreamingResponse
|
| 19 |
from fastapi.templating import Jinja2Templates
|
| 20 |
+
from fastapi.staticfiles import StaticFiles # NEW
|
| 21 |
+
|
| 22 |
|
| 23 |
# βββ Locate templates folder absolute path ββββββββββββββββββββββββββββββββββββ
|
| 24 |
BASE_DIR = Path(__file__).resolve().parent
|
| 25 |
templates = Jinja2Templates(directory=str(BASE_DIR / "templates"))
|
| 26 |
|
| 27 |
+
def include_in_app(app):
|
| 28 |
+
"""
|
| 29 |
+
Helper so the main application can pull in both router *and* static mount.
|
| 30 |
+
"""
|
| 31 |
+
app.include_router(router)
|
| 32 |
+
app.mount(
|
| 33 |
+
"/static",
|
| 34 |
+
StaticFiles(directory=str(BASE_DIR / "static")),
|
| 35 |
+
name="static",
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
# βββ Environment βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 39 |
TOKEN = os.getenv("BOT_TOKEN")
|
| 40 |
FALLBACK_IMG = "https://telegram.org/img/t_logo.png"
|