-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
38 lines (33 loc) · 1.2 KB
/
example.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
import arrow
import json
import logging
import requests
from initial_data import TVS
logging.basicConfig(level=logging.INFO)
if __name__ == '__main__':
response = requests.get(url='http://localhost:5000')
logging.info(response.text)
for tv in TVS[:5]:
tv['airdate'] = arrow.get(tv['airdate'], ['YYYY-MM-DD', 'MMMM D, YYYY']).timestamp
response = requests.put(
url='http://localhost:5000/episode/{number}'.format(number=tv['number']),
data=json.dumps(tv))
logging.info(response.text)
# get episode data
response = requests.get(
url='http://localhost:5000/episode/{number}'.format(number=2))
logging.info(response.text)
# remove
response = requests.delete(
url='http://localhost:5000/episode/{number}'.format(number=3))
logging.info(response.text)
# scan items
response = requests.get(
url='http://localhost:5000/episodes?limit={limit}&last={last}'.format(
limit=2, last=2))
logging.info(response.text)
# search
logging.info('Search results:')
response = requests.get(
url='http://localhost:5000/search?q={q}'.format(q='Stray Dog Strut'))
logging.info(response.text)