35 lines
1004 B
Python
35 lines
1004 B
Python
from flask import Flask, request, render_template
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
# Option A: Direkt die Python-Funktion ausführen (wenn dein Spiel in demselben Prozess laufen darf)
|
|
# from global_match_memory import run_memory
|
|
|
|
@app.get("/")
|
|
def home():
|
|
return render_template("index.html")
|
|
|
|
|
|
@app.get("/start")
|
|
def start_game():
|
|
players = request.args.get("players", "1")
|
|
# --- Option A: direkt aufrufen ---
|
|
# run_memory(int(players))
|
|
# return "started"
|
|
|
|
# --- Option B: separates Fenster/Prozess (robuster) ---
|
|
# Startet global_match_memory.py als eigenen Prozess mit Argument "players"
|
|
py = sys.executable # aktueller Python-Interpreter
|
|
script_path = os.path.join(os.path.dirname(__file__), "global_match_memory.py")
|
|
subprocess.Popen([py, script_path, players])
|
|
return "started"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# Auf Mac/Windows lokal erreichbar: http://localhost:5000
|
|
app.run(host="127.0.0.1", port=5000, debug=True)
|