Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update project to use only one port #5

Open
SandraRodgers opened this issue Jun 6, 2024 · 0 comments
Open

Update project to use only one port #5

SandraRodgers opened this issue Jun 6, 2024 · 0 comments

Comments

@SandraRodgers
Copy link
Contributor

A suggestion made by @etiennecallies is to update the project to use only one port. See discussion at: #4

This could be done by implementing the following:

from flask import Flask, render_template, session
from flask_socketio import SocketIO

FLASK_HOST = "127.0.0.1"
FLASK_PORT = "5001"
FLASK_DEBUG = "True"

app = Flask("deep_audio_ai")
socketio = SocketIO(app, cors_allowed_origins=[f"http://{FLASK_HOST}:{FLASK_PORT}"])

@app.route("/")
def index():
    return render_template("index.html")

@socketio.on("connect")
def handle_connect(auth):
    logging.info("Client connecting")
    socketio.start_background_task(target=on_connect)

...

if __name__ == "__main__":
    logging.info("Starting Flask")
    socketio.run(
        app,
        allow_unsafe_werkzeug=True,
        debug=FLASK_DEBUG == "True",
        host=FLASK_HOST,
        port=int(FLASK_PORT),
    )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant