mirror of
https://gitlab.com/RemixDev/deemix-gui-pyweb.git
synced 2025-01-01 12:26:13 +00:00
added support for pyinstaller onefile
This commit is contained in:
parent
900001efaf
commit
0b3f5f297d
14
server.py
14
server.py
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/env/bin python3
|
#!/usr/env/bin python3
|
||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
@ -29,10 +28,17 @@ class CustomFlask(Flask):
|
||||||
comment_end_string='#$',
|
comment_end_string='#$',
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def resource_path(relative_path):
|
||||||
|
""" Get absolute path to resource, works for dev and for PyInstaller """
|
||||||
|
try:
|
||||||
|
# PyInstaller creates a temp folder and stores path in _MEIPASS
|
||||||
|
base_path = sys._MEIPASS
|
||||||
|
except Exception:
|
||||||
|
base_path = path.dirname(path.abspath(__file__))
|
||||||
|
|
||||||
gui_dir = os.path.join(os.path.dirname(__file__), 'public') # development path
|
return path.join(base_path, relative_path)
|
||||||
if not os.path.exists(gui_dir): # frozen executable path
|
|
||||||
gui_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'public')
|
gui_dir = resource_path("public")
|
||||||
server = CustomFlask(__name__, static_folder=gui_dir, template_folder=gui_dir)
|
server = CustomFlask(__name__, static_folder=gui_dir, template_folder=gui_dir)
|
||||||
server.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1 # disable caching
|
server.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1 # disable caching
|
||||||
socketio = SocketIO(server)
|
socketio = SocketIO(server)
|
||||||
|
|
Loading…
Reference in a new issue