Last change
on this file was 895cd87, checked in by Marko <Marko@…>, 2 years ago |
Refactored code
|
-
Property mode
set to
100644
|
File size:
557 bytes
|
Line | |
---|
1 | import json
|
---|
2 |
|
---|
3 | import psycopg2
|
---|
4 | import requests
|
---|
5 | import config_read
|
---|
6 | import sys
|
---|
7 |
|
---|
8 | file_path = 'outputfile.txt'
|
---|
9 | sys.stdout = open(file_path, "w")
|
---|
10 |
|
---|
11 |
|
---|
12 | phones = json.loads(requests.get('http://localhost:8080/phones').text)
|
---|
13 |
|
---|
14 | for phone in phones:
|
---|
15 |
|
---|
16 | phone_id = str(phone['id'])
|
---|
17 | totaloffers = requests.get('http://localhost:8080/totaloffers/'+str.join('*', phone['model'].split(' '))).text
|
---|
18 |
|
---|
19 | print(phone_id+' - '+totaloffers)
|
---|
20 |
|
---|
21 | # UPDATE DATABASE WITH NEW TOTAL OFFERS
|
---|
22 | requests.put('http://localhost:8080/settotaloffers/' + phone_id + '/' + totaloffers)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.