diff --git a/.gitignore b/.gitignore index 7198a04..fafc987 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/__pycache__/** +**/venv/** databases/** json/** -static/** +**/static/resources/** \ No newline at end of file diff --git a/greendam_website b/greendam_website index 938c719..df67ba4 100755 --- a/greendam_website +++ b/greendam_website @@ -1,2 +1,2 @@ #!/bin/sh -docker run -it -d --name greendam_website -v $(pwd)/var:/var -w /var -p 0.0.0.0:8088:8084 skimrme/python:fastapi2 uvicorn main:app --host 0.0.0.0 --port 8084 --reload +docker run -it -d --name greendam_website -v $(pwd)/var:/var -w /var -p 0.0.0.0:8088:8084 skimrme/python:fastapi2 /var/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8084 --reload \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ca8c1b3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,17 @@ +annotated-doc==0.0.4 +annotated-types==0.7.0 +anyio==4.12.0 +certifi==2025.11.12 +charset-normalizer==3.4.4 +click==8.3.1 +fastapi==0.124.4 +h11==0.16.0 +idna==3.11 +pydantic==2.12.5 +pydantic_core==2.41.5 +requests==2.32.5 +starlette==0.50.0 +typing-inspection==0.4.2 +typing_extensions==4.15.0 +urllib3==2.6.2 +uvicorn==0.38.0 diff --git a/var/main.py b/var/main.py index 0934a39..1219367 100644 --- a/var/main.py +++ b/var/main.py @@ -1,20 +1,48 @@ -from fastapi import FastAPI -from fastapi import APIRouter # 引入模板 +from fastapi import FastAPI, Request +from fastapi import APIRouter # 引入路由表 from fastapi.staticfiles import StaticFiles # 设定静态文件夹 +from fastapi.templating import Jinja2Templates # 引入jinja模板 +from fastapi.responses import RedirectResponse # 重定向工具 # 初始化程序 -app = FastAPI() +app = FastAPI( + docs_url=None, + redoc_url=None +) root_url = "greendam.ww3.tw" # 设定静态文件夹 包括挂载位置 app.mount("/static", StaticFiles(directory="/var/static"), name="static") -# 模板文件 +# 设定jinja模板位置 +templates = Jinja2Templates(directory="templates") + +# 路由表文件 from routers import api app.include_router(api.router) - @app.get("/") -def home(): - return "Hello, World!!!" +async def reload_301_home(): + return RedirectResponse(url="https://greendam.ww3.tw/home/") + +@app.get("/docs") +@app.get("/docs/") +@app.get("/redoc") +@app.get("/redoc/") +async def reload_301(): + return RedirectResponse(url="https://greendam.ww3.tw/home/") + +@app.get("/home/") +async def home(request: Request): + return templates.TemplateResponse( + "home.html", + {"request": request} + ) + +@app.get("/resources/") +async def resources(request: Request): + return templates.TemplateResponse( + "resources.html", + {"request": request} + ) \ No newline at end of file diff --git a/var/static/src/css/home/main.css b/var/static/src/css/home/main.css new file mode 100644 index 0000000..06cb3f2 --- /dev/null +++ b/var/static/src/css/home/main.css @@ -0,0 +1,7 @@ +#home_wallpaper { + background: linear-gradient(to top, #228C23 50%, #53A14E 50%); +} + +#thanks { + font-size: 175%; +} \ No newline at end of file diff --git a/var/static/src/img/logo.png b/var/static/src/img/logo.png new file mode 100644 index 0000000..826eb3d Binary files /dev/null and b/var/static/src/img/logo.png differ diff --git a/var/templates/home.html b/var/templates/home.html new file mode 100644 index 0000000..3aa9858 --- /dev/null +++ b/var/templates/home.html @@ -0,0 +1,55 @@ + + + 绿坝娘资源小站 (仮) | home + + + + + +
+
+

绿坝娘资源小站 ()

+
+
+
+
+
+ + + +
+ 这是一个文件下载地址 +
+ 我会在这里提供一些,关于绿坝娘的文件 +
+ 来提供大家下载 +
+ 在此特别感谢荧瞳大大的提供 +
+
+
+
+
+
+
+
+
  • + 主页 + 资源 + 论坛 +
  • +
    +
    + 看来我的野心还不小啊!上来就作这么多功能!! +
    + 目前firefox是有问题的,但是我个人并不在windows使用firefox,故而不考虑适配 +
    +
    + 随机绿坝娘网站 +
    + https://greendam.icu/ +
    + + \ No newline at end of file diff --git a/var/templates/resources.html b/var/templates/resources.html new file mode 100644 index 0000000..d800886 --- /dev/null +++ b/var/templates/resources.html @@ -0,0 +1 @@ +123 \ No newline at end of file