miguelgrinberg / turbo-flask

Integration of Hotwire's Turbo library with Flask.
MIT License
301 stars 35 forks source link

No value updated #23

Closed SlodeSoft closed 2 years ago

SlodeSoft commented 2 years ago

Flask-2.0.2 python 3.6.8 Turbo_Flask-0.8.0

# [...]
import threading
import time
from datetime import datetime
from uptime import boottime
from turbo_flask import Turbo
# [...]

turbo = Turbo(app)

def update_load():
    with app.app_context():
        while True:
            turbo.push(turbo.replace(render_template('testturbo.html'), 'load'))
            time.sleep(1)

@app.before_first_request
def before_first_request():
    threading.Thread(target=update_load).start()

@app.route("/test")
def test():
    return render_template('testturbo.html')

@app.context_processor
def inject_load():
    return {"available": psutil.virtual_memory().available,
                                  "used": psutil.virtual_memory().used,
                                  "percent": psutil.virtual_memory().percent,
                                  "total": psutil.virtual_memory().total}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {{ turbo(app) }}
    <title>Title</title>
</head>
<body>
<div id="load" class="load">
    {{ available }}
</div>
</body>
</html>

Value stay stuck, no update display !

No error logs

SlodeSoft commented 2 years ago

After created a new virtualenv with python 3.9.6 and install all lib same issue :(

SlodeSoft commented 2 years ago

My fault, Nginx configuration CSP script-srv for *.skypack.dev But now get = WebSocket connection to 'wss://cru.viapass-xpress.com/turbo-stream' failed: Nginx again ! i wil update my issue.

SlodeSoft commented 2 years ago

No websockets available