switched cron job to http request
This commit is contained in:
17
app.py
17
app.py
@@ -31,6 +31,23 @@ def getAllAuctions(countrycode):
|
||||
print_exc(e)
|
||||
return 'internal server error', 500
|
||||
|
||||
@app.route("/v2/refreshauction/<countrycode>")
|
||||
def refreshAllAuctions(countrycode):
|
||||
try:
|
||||
if countrycode not in ['NL', 'BE', 'DE']:
|
||||
log('country not available: ' + countrycode)
|
||||
return jsonify('NOT AVAILABLE COUNTRY')
|
||||
|
||||
res = getAuctionlocations(countrycode, True)
|
||||
return JsonEncoder().encode(res)
|
||||
|
||||
except Exception as e:
|
||||
log('something went wrong with refreshing the auctions')
|
||||
print_exc(e)
|
||||
return 'internal server error' + e, 500
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run() # run our Flask app
|
||||
|
||||
|
||||
2
cache.py
2
cache.py
@@ -67,5 +67,5 @@ class FileCache():
|
||||
def add(key, obj):
|
||||
log('adding filecacheobject ' + key)
|
||||
json_data = JsonEncoder().encode(obj)
|
||||
with open("./filecache/" + key + ".json", 'w') as f:
|
||||
with open("./filecache/" + key + ".json", 'w+') as f:
|
||||
f.write(json_data)
|
||||
26
runapi.py
26
runapi.py
@@ -1,16 +1,16 @@
|
||||
# import requests
|
||||
from utils.auctionutils import getAuctionlocations
|
||||
import requests
|
||||
# from utils.auctionutils import getAuctionlocations
|
||||
|
||||
try:
|
||||
getAuctionlocations('NL', True)
|
||||
print('ran getauctions request successfull')
|
||||
except Exception as e:
|
||||
print('A error occurred while running the getauctions request')
|
||||
print(e)
|
||||
|
||||
|
||||
# response = requests.get('https://api.auctionviewer.ikbenhenk.nl//v2/auction/NL')
|
||||
# if(response.status_code ==200):
|
||||
# try:
|
||||
# getAuctionlocations('NL', True)
|
||||
# print('ran getauctions request successfull')
|
||||
# else:
|
||||
# except Exception as e:
|
||||
# print('A error occurred while running the getauctions request')
|
||||
# print(e)
|
||||
|
||||
|
||||
response = requests.get('https://api.auctionviewer.ikbenhenk.nl//v2/refreshauction/NL')
|
||||
if(response.status_code ==200):
|
||||
print('ran getauctions request successfull')
|
||||
else:
|
||||
print('A error occurred while running the getauctions request')
|
||||
Reference in New Issue
Block a user