-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestserver.py
50 lines (35 loc) · 955 Bytes
/
testserver.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
from socks import Socks, Response, ErrorResponse, renderTemplate
from socks.constants import *
app = Socks()
app2 = Socks(prefix="/app2")
app3 = Socks(prefix="/app3")
app2.register_subapp(app3)
app.register_subapp(app2)
@app.route("/", methods=["GET", "POST"])
def index(req):
return Response(
"<h1>"
+ req.method
+ "</h1>"
+ (("<p>BODY: " + req.body) if not req.method == "GET" else ""),
contentType="text/html",
)
@app.route("/test_error_code")
def test_error_code(req):
res = renderTemplate(
"test.html",
code=req.params.get("code"),
desc=ERROR_CODES[str(req.params.get("code"))],
)
return res
@app.route("/error_resp")
def error_resp(req):
return ErrorResponse(403)
@app2.route("/")
def test_app_2(req):
return "Test2"
@app3.route("/")
def test_app_2(req):
return "Test3"
if __name__ == "__main__":
app.run(reload=True, host="0.0.0.0")