forked from huderlem/maize-event
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdesktop.py
More file actions
37 lines (32 loc) · 1.1 KB
/
desktop.py
File metadata and controls
37 lines (32 loc) · 1.1 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
import webview
import threading
import sys
from app import app # Import the Flask app instance
# --- Configuration ---
URL = "http://127.0.0.1:5000"
TITLE = "Pokémon Maize Event Giveaway"
# -------------------
def run_flask():
"""Function to run Flask in a separate thread."""
try:
app.run(host='127.0.0.1', port=5000, debug=False)
except Exception as e:
print(f"Error starting Flask: {e}")
# In a real app, you might want to log this to a file
def main():
"""Main function to start the application."""
# 1. Start the Flask server in a background thread.
flask_thread = threading.Thread(target=run_flask)
flask_thread.daemon = True
flask_thread.start()
# 2. Create and show the pywebview window.
try:
window = webview.create_window(TITLE, URL, width=1280, height=720, resizable=True)
webview.start(debug=False) # debug=False for production
except Exception as e:
print(f"Error creating the application window: {e}")
finally:
# Ensure the program exits correctly
sys.exit()
if __name__ == '__main__':
main()