-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrunLocalServer.py
More file actions
84 lines (66 loc) · 2.15 KB
/
Copy pathrunLocalServer.py
File metadata and controls
84 lines (66 loc) · 2.15 KB
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
from flask import Flask, Response, send_from_directory, request
import requests
import urllib.parse
import re
app = Flask(__name__)
app.config.from_object(__name__)
@app.route('/audio/<int:path>')
def send_audio(path):
data = {
"gameVersion": "21",
"binaryVersion": "35",
"secret": "Wmfd2893gb7",
"songID": path
}
headers = {
"User-Agent": "",
}
req = requests.post("http://www.boomlings.com/database/getGJSongInfo.php", data=data, headers=headers)
downloadPath = re.compile(r"10~\|~(.*).mp3").search(req.text)
if (downloadPath == None):
return Response("Song not found", status=404)
downloadPath = urllib.parse.unquote(downloadPath.group(1)) + ".mp3"
host = urllib.parse.urlparse(downloadPath).netloc
headers = {
"Host": host,
"Range": request.headers.get("Range"),
}
res = requests.get(downloadPath, headers=headers)
return res.content, res.status_code, res.headers.items()
@app.route('/level/<int:id>')
def level(id):
data = {
"gameVersion": "21",
"binaryVersion": "35",
"secret": "Wmfd2893gb7",
"levelID": id,
}
headers = {
"User-Agent": "",
}
req = requests.post("http://www.boomlings.com/database/downloadGJLevel22.php", data=data, headers=headers)
return req.text
@app.route('/search/', defaults={'string': ''})
@app.route('/search/<string:string>')
def search(string):
data = {
"gameVersion": "21",
"binaryVersion": "35",
"secret": "Wmfd2893gb7",
"str": urllib.parse.unquote(string),
"type": "0",
}
headers = {
"User-Agent": "",
}
req = requests.post("http://www.boomlings.com/database/getGJLevels21.php", data=data, headers=headers)
return req.text
@app.route('/', defaults={'path': 'index.html'})
@app.route('/<path:path>')
def index(path):
res = send_from_directory('./frontend/dist', path);
res.headers['Cross-Origin-Embedder-Policy'] = 'require-corp'
res.headers['Cross-Origin-Opener-Policy'] = 'same-origin'
return res
if __name__ == '__main__':
app.run(port=8000)