switched cron job to http request

This commit is contained in:
Computerboer
2024-10-19 14:43:21 +02:00
parent 5f6ae49922
commit a0e87927af
3 changed files with 32 additions and 15 deletions

17
app.py
View File

@@ -31,6 +31,23 @@ def getAllAuctions(countrycode):
print_exc(e) print_exc(e)
return 'internal server error', 500 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__": if __name__ == "__main__":
app.run() # run our Flask app app.run() # run our Flask app

View File

@@ -67,5 +67,5 @@ class FileCache():
def add(key, obj): def add(key, obj):
log('adding filecacheobject ' + key) log('adding filecacheobject ' + key)
json_data = JsonEncoder().encode(obj) 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) f.write(json_data)

View File

@@ -1,16 +1,16 @@
# import requests import requests
from utils.auctionutils import getAuctionlocations # from utils.auctionutils import getAuctionlocations
try: # try:
getAuctionlocations('NL', True) # 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):
# print('ran getauctions request successfull') # print('ran getauctions request successfull')
# else: # except Exception as e:
# print('A error occurred while running the getauctions request') # 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')