Last change
on this file since 47f4eaf was 895cd87, checked in by Marko <Marko@…>, 21 months ago |
Refactored code
|
-
Property mode
set to
100644
|
File size:
557 bytes
|
Rev | Line | |
---|
[895cd87] | 1 | import json
|
---|
[527b93f] | 2 |
|
---|
| 3 | import psycopg2
|
---|
[895cd87] | 4 | import requests
|
---|
[527b93f] | 5 | import config_read
|
---|
| 6 | import sys
|
---|
| 7 |
|
---|
| 8 | file_path = 'outputfile.txt'
|
---|
| 9 | sys.stdout = open(file_path, "w")
|
---|
| 10 |
|
---|
| 11 |
|
---|
[895cd87] | 12 | phones = json.loads(requests.get('http://localhost:8080/phones').text)
|
---|
[527b93f] | 13 |
|
---|
| 14 | for phone in phones:
|
---|
| 15 |
|
---|
[895cd87] | 16 | phone_id = str(phone['id'])
|
---|
| 17 | totaloffers = requests.get('http://localhost:8080/totaloffers/'+str.join('*', phone['model'].split(' '))).text
|
---|
[527b93f] | 18 |
|
---|
[895cd87] | 19 | print(phone_id+' - '+totaloffers)
|
---|
[527b93f] | 20 |
|
---|
[895cd87] | 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.