cheekeong2025 commited on
Commit
20970e9
·
verified ·
1 Parent(s): 7f5f2e3

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -41
app.py DELETED
@@ -1,41 +0,0 @@
1
- import os
2
- from fastapi import FastAPI, Request, Depends
3
- from fastapi.responses import HTMLResponse, RedirectResponse
4
- from fastapi.security import HTTPBasic, HTTPBasicCredentials
5
-
6
- app = FastAPI()
7
- security = HTTPBasic()
8
-
9
- PASSWORD = os.getenv("SPACE_PASSWORD", "secret123")
10
-
11
- def check_auth(credentials: HTTPBasicCredentials = Depends(security)):
12
- if credentials.password == PASSWORD:
13
- return True
14
- return False
15
-
16
- @app.get("/", response_class=HTMLResponse)
17
- def login_page():
18
- return """
19
- <html><body>
20
- <h2>🔒 Protected Space</h2>
21
- <p>Enter password to access:</p>
22
- <form action="/go" method="post">
23
- <input type="password" name="pwd" />
24
- <input type="submit" value="Enter" />
25
- </form>
26
- </body></html>
27
- """
28
-
29
- @app.post("/go")
30
- async def go(request: Request):
31
- form = await request.form()
32
- pwd = form.get("pwd")
33
- if pwd == PASSWORD:
34
- return RedirectResponse("/proxy", status_code=302)
35
- else:
36
- return HTMLResponse("<h3>❌ Incorrect password</h3>", status_code=401)
37
-
38
- @app.get("/proxy")
39
- def proxy():
40
- # Redirect to the internal Transformer Lab app
41
- return RedirectResponse("http://localhost:8338")