commit a8383c801933c59ad6d157f53f9022f937fe25ea Author: passthem Date: Mon Oct 27 14:55:00 2025 +0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..033df5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.venv +__pycache__ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..aa4e727 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.11-alpine + +WORKDIR /app +COPY requirements.txt . +RUN python -m pip install --no-cache-dir -r requirements.txt + +COPY index.html . +COPY main.py . +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] + diff --git a/index.html b/index.html new file mode 100644 index 0000000..0dd1336 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + 小司的个人网站 + + + +

小司的个人网站

+

大家好!欢迎来到我的个人网站!

+
+ + + + + +
+ + + diff --git a/main.py b/main.py new file mode 100644 index 0000000..b56364e --- /dev/null +++ b/main.py @@ -0,0 +1,39 @@ +from pathlib import Path +from typing import Annotated + +import uvicorn +from fastapi import FastAPI, Form +from fastapi.responses import HTMLResponse, PlainTextResponse + + +app = FastAPI() + +SECRET_PATH = Path("./secret/flag.txt") +HTML_PATH = Path("./index.html") + + +if not SECRET_PATH.exists(): + flag = "konaph{example_flag}" +else: + flag = SECRET_PATH.read_text() + + +@app.get("/") +async def _() -> HTMLResponse: + return HTMLResponse(content=HTML_PATH.read_text()) + + +@app.post("/login") +async def _(username: Annotated[str, Form()], password: Annotated[str, Form()]): + if username == "im_tsukasa" and password == "ker0r0_k4w4ii": + return PlainTextResponse(f"登录成功!答案为 {flag}。\n给此方 BOT 私发:提交答案 {flag}") + return PlainTextResponse("用户名或密码错误!", status_code=401) + + +if __name__ == "__main__": + uvicorn.run( + app=app, + host="0.0.0.0", + port=8000, + ) + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1363737 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +fastapi +uvicorn +python-multipart