-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
43 lines (33 loc) · 735 Bytes
/
server.py
File metadata and controls
43 lines (33 loc) · 735 Bytes
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
#!/usr/bin/env python3
"""
/dev/null: Take what you can, give nothing back.
"""
from flask import Flask, request, url_for, redirect
app = Flask(__name__)
methods = [
"HEAD",
"GET",
"OPTIONS",
"TRACE",
"CONNECT",
"POST",
"PUT",
"PATCH",
"DELETE",
]
@app.errorhandler(404)
def dev_null_redirect(_):
"""
Redirect everything to `/dev/null'.
"""
return redirect(url_for("serve"))
@app.route("/dev/null", methods=methods)
def serve():
"""
This is the default route. Doesn't do anything.
"""
if request.method in ["POST", "PUT", "PATCH"]:
return ("", 204)
return ("", 200)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080, debug=False)