forked from mc-17/pspack-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
51 lines (39 loc) · 1.33 KB
/
app.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
import os
from flask import Flask, render_template, request
from urllib.parse import unquote_plus
from sender import send
app = Flask(__name__)
@app.route('/')
def index():
ua = request.headers.get("User-Agent", None)
if ua:
ua_part = ua[ua.index("PlayStation 4/") + len("PlayStation 4/"):]
ua_part = ua_part[:ua_part.index(")")]
else:
ua_part = ua
return render_template("index.html", version=ua_part)
@app.route("/log/<msg>")
def log(msg):
msg = unquote_plus(msg)
if "done" in msg or "already" in msg:
# success message, send HEN
print(f"Sending golden hen to {request.remote_addr}")
send(request.remote_addr, 9020, "payload/goldhen_2.0b_900.bin")
print(msg)
return "OK"
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r
if __name__ == '__main__':
app.add_url_rule(app.static_url_path + '/<path:filename>',
endpoint='static',
view_func=app.send_static_file)
app.run(host="0.0.0.0")