完成基础页面构建

This commit is contained in:
2026-05-19 00:56:48 +00:00
parent cf6910c72c
commit a06a0cead0
6 changed files with 100 additions and 8 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
**/__pycache__/**
**/venv/**
databases/**
json/**
static/**
**/static/resources/**

View File

@@ -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}
)

View File

@@ -0,0 +1,7 @@
#home_wallpaper {
background: linear-gradient(to top, #228C23 50%, #53A14E 50%);
}
#thanks {
font-size: 175%;
}

BIN
var/static/src/img/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 KiB

55
var/templates/home.html Normal file
View File

@@ -0,0 +1,55 @@
<html>
<head>
<title>绿坝娘资源小站 (仮) | home</title>
<link rel="stylesheet" href="/static/src/css/home/main.css">
<link rel="icon" type="image/png" sizes="128x128" href="/static/src/img/logo.png">
</head>
<body id="home_wallpaper">
<!-- <div style="height: 20%; width: 200px; background-color: aqua;">
<img src="/static/src/img/logo.png" alt="logo" style="width: 20%;">
</div> -->
<div style="width: 100%; height: 100%;">
<div style="width: 60%; text-align: right;">
<h1>绿坝娘资源小站 (<a style="color: white;"></a>)</h1>
</div>
<br>
<br>
<br>
<div style="width: 100%;">
<table border="0" style="width: 100%;">
<th style="width: 20%;"></th>
<th style="color: rgb(43, 43, 43); font-size: 120%; text-align: left;">
这是一个文件下载地址
<br>
我会在这里提供一些,关于绿坝娘的文件
<br>
来提供大家下载
<br>
在此特别感谢荧瞳大大的提供
</th>
</table>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<li style="font-size: 600%; width: 65%; height: 25%; text-align: right;">
<a href="#">主页</a>
<a href="/resources/">资源</a>
<a href="#">论坛</a>
</li>
<br>
<br>
<del>看来我的野心还不小啊!上来就作这么多功能!!</del>
<br>
目前firefox是有问题的但是我个人并不在windows使用firefox故而不考虑适配
<br>
<br>
随机绿坝娘网站
<br>
<a href="https://greendam.icu/">https://greendam.icu/</a>
</div>
</body>
</html>

View File

@@ -0,0 +1 @@
123