docker 完成

This commit is contained in:
jeremygan2021
2026-01-06 17:02:06 +08:00
parent 0fcdfd36e2
commit 9ed51276a5
4 changed files with 29 additions and 3 deletions

1
.env.example Normal file
View File

@@ -0,0 +1 @@
ADD_USER_SECRET=123quant-speed

17
.gitignore vendored Normal file
View File

@@ -0,0 +1,17 @@
__pycache__/
*.py[cod]
*.log
.DS_Store
.env
.env.*
!.env.example
env/
venv/
.venv/
staticfiles/
media/
.idea/
.vscode/
*.tar
*.mp3

View File

@@ -9,6 +9,9 @@ from typing import Optional, List, Dict
import random import random
import uuid import uuid
import os import os
from dotenv import load_dotenv
load_dotenv()
app = FastAPI() app = FastAPI()
@@ -277,7 +280,9 @@ async def checkin_user(checkin_data: CheckinRequest):
@app.get("/add-user", response_class=HTMLResponse) @app.get("/add-user", response_class=HTMLResponse)
async def add_user_page(request: Request): async def add_user_page(request: Request):
return templates.TemplateResponse("add_user.html", {"request": request}) secret = os.getenv("ADD_USER_SECRET", "123quant-speed")
print(f"DEBUG: Secret loaded: '{secret}'")
return templates.TemplateResponse("add_user.html", {"request": request, "secret": secret})
@app.post("/api/add-user") @app.post("/api/add-user")
async def add_user_api(user_data: AddUserRequest): async def add_user_api(user_data: AddUserRequest):
@@ -322,4 +327,4 @@ async def add_user_api(user_data: AddUserRequest):
if __name__ == "__main__": if __name__ == "__main__":
import uvicorn import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8800) uvicorn.run(app, host="0.0.0.0", port=8000)

View File

@@ -297,13 +297,16 @@
</div> </div>
<script> <script>
// Use secret from backend
const ACCESS_SECRET = "{{ secret }}";
// Password Check Logic // Password Check Logic
function checkSecret() { function checkSecret() {
const input = document.getElementById('secret-input'); const input = document.getElementById('secret-input');
const error = document.getElementById('secret-error'); const error = document.getElementById('secret-error');
const overlay = document.getElementById('password-overlay'); const overlay = document.getElementById('password-overlay');
if (input.value === '123quant-speed') { if (input.value === ACCESS_SECRET) {
overlay.style.opacity = '0'; overlay.style.opacity = '0';
setTimeout(() => { setTimeout(() => {
overlay.style.display = 'none'; overlay.style.display = 'none';