-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
68 lines (48 loc) · 1.75 KB
/
Copy pathapp.py
File metadata and controls
68 lines (48 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Axie Tracker System
# Created by John Rey Vilbar (in compliance for ITE152)
# This is a refactored version of the original system
import eel
import bottle
import platform
import backend.database as db
import backend.hide_console as hide_console
import backend.logger as logger
import backend.server.eel_expose as expose
# Initialize python eel
eel.init('web')
# Set logger
logger.set_logging()
# Initialize and test database connection
db.initialize()
test_db = db.test_connection()
if not test_db:
raise Exception("Database connection failed.")
#smooth-love-potion = SLP
#axie-infinity = AXS
#more in https://docs.google.com/spreadsheets/d/1wTTuxXt8n9q7C4NDXqQpI3wpKu1_5bGVmP9Xz0XGSyU/edit?usp=sharing
# Hide the python console when clicking the app.py (in Windows only)
if platform.system() == 'Windows':
hide_console.hide_console()
# Use Bottle to serve static files rather than Eel in order to load the files faster
@bottle.route('/static/<filepath:path>')
def server_static(filepath):
response = bottle.response
response.set_header('Cache-Control', 'no-cache, no-store, must-revalidate')
response.set_header('Pragma', 'no-cache')
response.set_header('Expires', '0')
return bottle.static_file(filepath, root='static')
# Expose python functions to JavaScript
expose.register_exposed_functions()
if __name__ == '__main__':
try:
logger.logging.info("Eel session running.")
eel.start('login.html',
mode='chrome',
host='localhost',
port=8000,
cmdline_args=['--start-maximized'],
shutdown_delay=3,
disable_cache=True,
)
except OSError:
logger.logging.error(f"Error: {OSError}")