-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (27 loc) · 925 Bytes
/
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
import base64
from flask import Flask, request, json
from waitress import serve
app = Flask(__name__)
list_decode = lambda inp: [x for x in base64.b64decode(inp).decode().split("#")]
@app.route("/get/<id>", methods=["GET"])
def get(id):
try:
out = list_decode(id)
except:
return "error", 400
with open("default.html", "r") as f:
html_raw = f.read()
ans = ""
for i, v in enumerate(out, 1):
if not "[" in v:
ans += f"{i}. {v}<br>"
elif "[" in v:
tmp = [x.strip() for x in v.strip()[1:-1].split(",")]
ans += f"{i}. <br>"
for j, w in enumerate(tmp, 0):
ans += f" {chr(j+ord('a'))}) {w}<br>"
html_raw = html_raw.replace("{%loesung%}", ans)
return html_raw, 200
if __name__ == "__main__":
app.run(debug=True)
# serve(app, host="127.0.0.1", port=5000)