Spaces:
Running
Running
from flask import Flask, render_template, session | |
from flask_socketio import SocketIO, emit | |
from game import Game | |
import uuid | |
import os | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = 'your-secret-key' # Replace with a secure key | |
# Configure SocketIO with eventlet for WebSocket support | |
socketio = SocketIO(app, | |
cors_allowed_origins="https://broadfield-dev-dungeon-game.hf.space", # Your Spaces URL | |
async_mode='eventlet') # Switch to eventlet | |
# Store game instances per client session | |
games = {} | |
# ... (rest of your app.py code remains the same) | |
if __name__ == '__main__': | |
# Use port 7860 for Hugging Face Spaces or environment variable | |
port = int(os.environ.get('PORT', 7860)) | |
socketio.run(app, debug=True, host='0.0.0.0', port=port) |