feat: 添加官网主页路由及静态文件支持
- 在 api/routers 中新增 home.py 路由,提供应用官网主页的 HTML 响应。 - 更新 main.py,包含 home 路由并挂载静态文件目录。 - 新增静态文件 home.html 和 avatar_assistant.png,丰富官网内容。 - 更新 .gitignore,确保 certs/ 目录被忽略。
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -54,4 +54,4 @@ dist/
|
||||
# 本地 ASR 模型缓存(Whisper 每次启动从该目录加载)
|
||||
api/models/
|
||||
|
||||
certs/
|
||||
certs/
|
||||
@@ -8,6 +8,7 @@ from dotenv import load_dotenv, dotenv_values
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(
|
||||
@@ -54,7 +55,7 @@ else:
|
||||
from database import init_db
|
||||
from routers import (
|
||||
websocket, chapters, books, conversations, auth, memoir_state, tasks,
|
||||
user, plans, orders, faqs, quota, feedback, legal, payment
|
||||
user, plans, orders, faqs, quota, feedback, legal, payment, home
|
||||
)
|
||||
|
||||
# 初始化数据库
|
||||
@@ -172,6 +173,8 @@ app.include_router(faqs.router) # 常见问题路由
|
||||
app.include_router(quota.router) # 配额检查路由
|
||||
app.include_router(feedback.router) # 反馈路由
|
||||
app.include_router(legal.router) # 法律文档路由(用户协议、隐私政策)
|
||||
app.include_router(home.router) # 应用官网主页
|
||||
app.mount("/static", StaticFiles(directory=Path(__file__).parent / "static"), name="static")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
|
||||
22
api/routers/home.py
Normal file
22
api/routers/home.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
应用官网主页路由
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
router = APIRouter(tags=["home"])
|
||||
|
||||
_STATIC_DIR = Path(__file__).resolve().parent.parent / "static"
|
||||
|
||||
|
||||
@router.get("/home", response_class=HTMLResponse)
|
||||
async def get_home():
|
||||
"""
|
||||
应用官网主页
|
||||
|
||||
包含应用介绍、功能展示、下载链接、定价方案等
|
||||
"""
|
||||
html_path = _STATIC_DIR / "home.html"
|
||||
return HTMLResponse(content=html_path.read_text(encoding="utf-8"))
|
||||
BIN
api/static/avatar_assistant.png
Normal file
BIN
api/static/avatar_assistant.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
1368
api/static/home.html
Normal file
1368
api/static/home.html
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user