-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
119 lines (100 loc) · 3.79 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import httpx
from fastapi import FastAPI, Query, Request
from fastapi.responses import HTMLResponse, PlainTextResponse
from fastapi.staticfiles import StaticFiles
from route.login import router as login_router
from route.templates import templates
app = FastAPI()
client = httpx.AsyncClient()
app.include_router(login_router)
app.mount("/img", StaticFiles(directory="public/img"), name="img")
app.mount("/js", StaticFiles(directory="public/js"), name="js")
@app.get("/", response_class=HTMLResponse)
async def debug_challenge_page(
request: Request,
username: str = Query(..., title="username"),
command: str = Query(..., title="command"),
uid: str = Query(..., title="uid"),
gt: str = Query(..., title="gt"),
challenge: str = Query(..., title="challenge"),
):
user = {"username": username, "uid": uid, "command": command}
geetest = {
"gt": gt,
"challenge": challenge,
}
return templates.TemplateResponse(
"example.html", {"request": request, "user": user, "geetest": geetest}
)
@app.get("/webapp", response_class=HTMLResponse)
async def debug_challenge_page(
request: Request,
username: str = Query(..., title="username"),
command: str = Query(..., title="command"),
uid: str = Query(..., title="uid"),
gt: str = Query(..., title="gt"),
challenge: str = Query(..., title="challenge"),
user_id: str = Query("", title="user_id"),
):
user = {"username": username, "uid": uid, "command": command, "user_id": user_id}
geetest = {
"gt": gt,
"challenge": challenge,
}
return templates.TemplateResponse(
"webapp.html", {"request": request, "user": user, "geetest": geetest}
)
@app.get("/tasks1", response_class=HTMLResponse)
async def debug_tasks1_page(
request: Request,
command: str = Query(..., title="command"),
bot_data: str = Query(..., title="bot_data"),
):
user = {"command": command, "bot_data": bot_data}
return templates.TemplateResponse("tasks1.html", {"request": request, "user": user})
@app.get("/tasks2", response_class=HTMLResponse)
async def debug_tasks2_page(
request: Request,
command: str = Query(..., title="command"),
bot_data: str = Query(..., title="bot_data"),
):
user = {"command": command, "bot_data": bot_data}
return templates.TemplateResponse("tasks2.html", {"request": request, "user": user})
@app.get("/tasks3", response_class=HTMLResponse)
async def debug_tasks3_page(
request: Request,
command: str = Query(..., title="command"),
bot_data: str = Query(..., title="bot_data"),
):
user = {"command": command, "bot_data": bot_data}
return templates.TemplateResponse("tasks3.html", {"request": request, "user": user})
@app.get("/tasks4", response_class=HTMLResponse)
async def debug_tasks4_page(
request: Request,
command: str = Query(..., title="command"),
bot_data: str = Query(..., title="bot_data"),
):
user = {"command": command, "bot_data": bot_data}
return templates.TemplateResponse("tasks4.html", {"request": request, "user": user})
@app.get("/relic_property", response_class=HTMLResponse)
async def relic_property_page(
request: Request,
command: str = Query(..., title="command"),
name: str = Query(..., title="name"),
cid: str = Query(..., title="cid"),
recommend: str = Query(..., title="recommend"),
custom: str = Query(..., title="custom"),
):
user = {
"command": command,
"recommend": recommend,
"custom": custom,
"name": name,
"cid": cid,
}
return templates.TemplateResponse(
"relic_property.html", {"request": request, "user": user}
)
@app.get("/telegram-web-app.js", response_class=PlainTextResponse)
async def get_telegram_web_js():
return (await client.get("https://telegram.org/js/telegram-web-app.js")).text