Spaces:
Running
Running
File size: 796 Bytes
a78e101 6caeb35 a78e101 6caeb35 ca24c9d a78e101 ca24c9d a78e101 6caeb35 ca24c9d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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) |