This repository has been archived by the owner on Aug 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
81 lines (70 loc) · 1.79 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
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
from flask import Flask
from flask import request
from flaskext.mysql import MySQL
import requests
import os
app = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = os.environ['MYSQL_DATABASE_USER']
app.config['MYSQL_DATABASE_PASSWORD'] = os.environ['MYSQL_DATABASE_PASSWORD']
app.config['MYSQL_DATABASE_DB'] = os.environ['MYSQL_DATABASE_DB']
app.config['MYSQL_DATABASE_HOST'] = os.environ['MYSQL_DATABASE_HOST']
mysql.init_app(app)
base_url = 'http://demo7835208.mockable.io/'
'''
Status
'''
@app.route('/', methods=['GET'])
def home():
''' example connection
conn = mysql.connect()
try:
cursor = conn.cursor()
finally:
conn.close()
'''
return { 'msg': 'API OK' }
'''
get all series
TODO
filter by category
'''
@app.route('/series', methods=['GET'])
def get_series():
resp = requests.get(base_url + 'series')
return resp.text
'''
get series_id series information
TODO
read from service
'''
@app.route('/series/<series_id>', methods=['GET'])
def get_one_series(series_id):
if series_id is None:
return { 'msg': 'Serie' }
else:
return { 'msg': 'Serie: ' + series_id }
'''
save episode as watched
body: userId
TODO
connection to db
'''
@app.route('/series/<series_id>/episode/<episode_id>', methods=['POST'])
def save_watched_episode(series_id, episode_id):
if series_id is None or episode_id is None:
return { 'msg': 'Serie' }
else:
return { 'msg': 'Serie: ' + series_id + ' episode: ' + episode_id}
'''
delete episode as watched
body: userId
TODO
connection to db
'''
@app.route('/series/<series_id>/episode/<episode_id>', methods=['DELETE'])
def save_unwatched_episode(series_id, episode_id):
if series_id is None or episode_id is None:
return { 'msg': 'Serie' }
else:
return { 'msg': 'Serie: ' + series_id + ' episode: ' + episode_id}