#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from flask import Flask
from flask_restx import Api
from flask_socketio import SocketIO

from api import api_blueprint
from web.server import web_blueprint
from web.server import stream

app = Flask(__name__)

app.template_folder = "./web/pages"
app.static_folder = "./web/static"

# Initialize Flask-SocketIO
socketio = SocketIO(app,
                    async_mode='threading',
                    threaded=True,
                    path="/web/socket")

# Register blueprints
app.register_blueprint(api_blueprint, url_prefix='/api')
app.register_blueprint(web_blueprint, url_prefix='/web')

stream.start(socketio, app)

if __name__ == '__main__':
    socketio.run(app, "0.0.0.0", 5533, debug=False)
    
