Compare commits
4 Commits
6fe1292086
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 85e7887b65 | |||
| a7fe9d8614 | |||
| 0bfc2fd9c5 | |||
| 51d4f30de3 |
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Dockerfile
|
||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# (optioneel: system deps toevoegen als later nodig voor DB/libs)
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Python deps
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# App code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
# Simpel: zelfde als startup.bat, maar dan Linux
|
||||||
|
CMD ["python", "app.py"]
|
||||||
9
app.py
9
app.py
@@ -28,7 +28,7 @@ def getAllAuctions(countrycode):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log('something went wrong ')
|
log('something went wrong ')
|
||||||
print_exc(e)
|
print_exc()
|
||||||
return 'internal server error', 500
|
return 'internal server error', 500
|
||||||
|
|
||||||
@app.route("/v2/refreshauction/<countrycode>")
|
@app.route("/v2/refreshauction/<countrycode>")
|
||||||
@@ -43,12 +43,13 @@ def refreshAllAuctions(countrycode):
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log('something went wrong with refreshing the auctions')
|
log('something went wrong with refreshing the auctions')
|
||||||
print_exc(e)
|
print_exc()
|
||||||
return 'internal server error' + e, 500
|
return 'internal server error', 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run() # run our Flask app
|
app.run(host="0.0.0.0", port=5000) # ipv alleen app.run()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
cache.py
5
cache.py
@@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
@@ -69,5 +70,9 @@ class FileCache():
|
|||||||
log('adding filecacheobject ' + key)
|
log('adding filecacheobject ' + key)
|
||||||
json_data = JsonEncoder().encode(obj)
|
json_data = JsonEncoder().encode(obj)
|
||||||
# json_data = json.dumps(obj, cls=JsonEncoder, indent=2)
|
# json_data = json.dumps(obj, cls=JsonEncoder, indent=2)
|
||||||
|
|
||||||
|
# Ensure the filecache directory exists
|
||||||
|
os.makedirs("./filecache", exist_ok=True)
|
||||||
|
|
||||||
with open("./filecache/" + key + ".json", 'w+') as f:
|
with open("./filecache/" + key + ".json", 'w+') as f:
|
||||||
f.write(json_data)
|
f.write(json_data)
|
||||||
|
|||||||
@@ -11,6 +11,6 @@ import requests
|
|||||||
|
|
||||||
response = requests.get('https://api.auctionviewer.ikbenhenk.nl//v2/refreshauction/NL')
|
response = requests.get('https://api.auctionviewer.ikbenhenk.nl//v2/refreshauction/NL')
|
||||||
if(response.status_code ==200):
|
if(response.status_code ==200):
|
||||||
print('ran getauctions request successfull')
|
print('ran getauctions request successful')
|
||||||
else:
|
else:
|
||||||
print('A error occurred while running the getauctions request')
|
print('A error occurred while running the getauctions request')
|
||||||
Reference in New Issue
Block a user