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