mikeabrahamsen / Flask-Meld

Flask-Meld is a library to provide server rendered templates over websockets for Flask applications to build reactive components without Javascript
https://www.flask-meld.dev/
MIT License
313 stars 15 forks source link

example error 'Flask' object has no attribute 'socketio' #9

Closed edersohe closed 3 years ago

edersohe commented 3 years ago

The example cause this error

Traceback (most recent call last):
  File "wsgi.py", line 6, in <module>
    socketio = app.socketio
AttributeError: 'Flask' object has no attribute 'socketio'

I fixed putting scoketio initialization after meld initialization

from flask import Flask, render_template
from flask_meld import Meld

app = Flask(__name__)
app.config['SECRET_KEY'] = 'big!secret'

meld = Meld()
meld.init_app(app)

socketio = app.socketio

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

if __name__ == '__main__':
    socketio.run(app)