[Python] How to use Flask-SocketIO with Phusion Passenger?

Discussão em 'Python' iniciado por Stack, Dezembro 20, 2024.

  1. Stack

    Stack Membro Participativo

    Phusion Passenger needs to launch the webserver using its own function, so a custom function to launch a webserver cannot be used, while SocketIO seems to require to use one. Is there is any way to bypass this?

    Sample code:

    from flask import Flask
    from flask_socketio import SocketIO

    app = Flask('')
    socket = SocketIO(app)

    @app.route('/')
    def home():
    return open("index.html", "r").read()

    @socket.on('echo')
    def echo(json):
    return json

    # Phusion Passenger already does this, so we shouldnt run that next line or else we will never run the program
    #app.run(host='0.0.0.0',port=80)

    Continue reading...

Compartilhe esta Página