Finished serverside_modeling
This commit is contained in:
@@ -31,7 +31,6 @@
|
||||
<Compile Include="utils\auctionutils.py" />
|
||||
<Compile Include="cache.py" />
|
||||
<Compile Include="utils\locationutils.py" />
|
||||
<Compile Include="models\auction.py" />
|
||||
<Compile Include="models\location.py" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
22
app.py
22
app.py
@@ -6,10 +6,9 @@ from cache import Cache
|
||||
from utils.auctionutils import getTwkAuctions, getAuctionlocations
|
||||
from utils.locationutils import getGeoLocationByCity
|
||||
from models.location import JsonEncoder
|
||||
import json
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app, resources={r"/auction/*": {"origins": ["http://localhost:4200","https://auctionviewer.ikbenhenk.nl", "https://victorious-bay-0d278c903.3.azurestaticapps.net"]}})
|
||||
CORS(app, resources={r"/*": {"origins": ["http://localhost:4200","https://auctionviewer.ikbenhenk.nl", "https://victorious-bay-0d278c903.3.azurestaticapps.net"]}})
|
||||
application = app # our hosting requires application in passenger_wsgi
|
||||
|
||||
@app.route("/")
|
||||
@@ -17,7 +16,7 @@ def gethome():
|
||||
return "application is working!"
|
||||
|
||||
@app.route("/v2/auction/<countrycode>")
|
||||
def get(countrycode):
|
||||
def getAllAuctions(countrycode):
|
||||
try:
|
||||
if countrycode not in ['NL', 'BE', 'DE']:
|
||||
print(f'country not available: {countrycode} ')
|
||||
@@ -34,17 +33,24 @@ def get(countrycode):
|
||||
return 'internal server error', 500
|
||||
|
||||
|
||||
@app.route("/v1/auction/<countrycode>")
|
||||
def get(countrycode):
|
||||
@app.route("/auction/<countrycode>")
|
||||
def getTwkAuctions(countrycode):
|
||||
try:
|
||||
if countrycode not in ['NL', 'BE', 'DE']:
|
||||
print(f'country not available: {countrycode} ')
|
||||
return jsonify('NOT AVAILABLE COUNTRY')
|
||||
|
||||
res = Cache.get(countrycode)
|
||||
if(res):
|
||||
return res.obj
|
||||
|
||||
res = getAuctionlocations(countrycode)
|
||||
#return json.dumps(res, sort_keys=True, default=str)
|
||||
return JsonEncoder().encode(res)
|
||||
response = requests.get("https://api.troostwijkauctions.com/sale/4/listgrouped?batchSize=99999&CountryIDs=" + countrycode)
|
||||
print(f'request statuscode: {response.status_code} ')
|
||||
|
||||
if(response.status_code ==200):
|
||||
Cache.add(countrycode, response.json())
|
||||
|
||||
return response.json();
|
||||
|
||||
except Exception as e:
|
||||
print('something went wrong ')
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
from enum import Enum
|
||||
import numbers
|
||||
import string
|
||||
import json
|
||||
from json import JSONEncoder
|
||||
|
||||
class Countrycode(Enum):
|
||||
|
||||
@@ -2,4 +2,5 @@ pip==9.0.1
|
||||
setuptools==28.8.0
|
||||
flask===2.0.3
|
||||
flask_cors===3.0.10
|
||||
requests===2.27.1
|
||||
requests===2.27.1
|
||||
pathlib===1.0.1
|
||||
Reference in New Issue
Block a user