-
Notifications
You must be signed in to change notification settings - Fork 0
/
webserver.py
42 lines (28 loc) · 991 Bytes
/
webserver.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
from flask import Flask, request
import archive_playlist
import util.token_util
from constants.constants import ScriptType
app = Flask(__name__)
@app.route('/getRedirectUrl')
def get_auth_url():
return util.token_util.get_auth_url()
@app.route('/callback', methods=['POST'])
def callback():
if request.is_json:
url = request.get_json()
print(url['url'])
util.token_util.generate_token_from_url(url['url'])
return "Abruf erfolgreich", 200
return "Anforderung enthält kein JSON!", 400
@app.route('/run/release-radar')
def run_release_radar():
return archive_playlist.main(ScriptType.RELEASE_RADAR)
@app.route('/run/discover-weekly')
def run_discover_weekly():
return archive_playlist.main(ScriptType.DISCOVER_WEEKLY)
# todo:
# - endpoint to check if token file exists
# - endpoint to check how long till token expires
# 0.0.0.0 instead of localhost for docker
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8123)