Files
aupi/app.py
michael1986 0bfc2fd9c5
Some checks failed
Ik ben Henk python api ftp deploy / Deploy Python api (push) Has been cancelled
Dockerify
2025-12-01 13:18:53 +01:00

56 lines
1.6 KiB
Python

from utils.helperutils import log
from traceback import print_exc
from flask import Flask, jsonify
from flask_cors import CORS
from cache import Cache
from utils.auctionutils import getAuctionlocations
from models.location import JsonEncoder
app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": ["*"]}})
application = app # our hosting requires application in passenger_wsgi
@app.route("/")
def gethome():
return "application is working!"
@app.route("/v2/auction/<countrycode>")
def getAllAuctions(countrycode):
try:
if countrycode not in ['NL', 'BE', 'DE']:
log('country not available: ' + countrycode)
return jsonify('NOT AVAILABLE COUNTRY')
log('incoming api request')
res = getAuctionlocations(countrycode)
#return json.dumps(res, sort_keys=True, default=str)
return JsonEncoder().encode(res)
except Exception as e:
log('something went wrong ')
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(host="0.0.0.0", port=5000) # ipv alleen app.run()