fix flask turbo compatibilty with gunicorn

This commit is contained in:
GroovieGermanikus 2023-11-27 17:41:09 +01:00
parent 1ed8d6ef17
commit d0f29e784f
No known key found for this signature in database
GPG Key ID: 5B6EB831A5CD2015
3 changed files with 11 additions and 1 deletions

View File

@ -9,4 +9,6 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . /usr/src/app
EXPOSE 8080
CMD echo "$PGCACERT" | base64 --decode > ca.cer && echo "$PGCLIENTCERT" | base64 --decode > client.cer && echo "$PGCLIENTKEY" | base64 --decode > client-key.cer && gunicorn app:webapp --bind 0.0.0.0:8080
CMD \
echo "$PGCACERT" | base64 --decode > ca.cer && echo "$PGCLIENTCERT" | base64 --decode > client.cer && echo "$PGCLIENTKEY" | base64 --decode > client-key.cer && \
gunicorn app:webapp --threads 100 --bind 0.0.0.0:8080

View File

@ -22,6 +22,11 @@ source .venv/bin/activate
SOLANA_CLUSTER=testnet PGDATABASE=da11copy PGUSER=query_user PGPASSWORD=secret TEMPLATES_AUTO_RELOAD=True flask run --port 5050 --debug --reload
```
Use this to test with _gunicorn_:
```
SOLANA_CLUSTER=testnet PGDATABASE=da11copy PGPORT=5432 PGUSER=query_user PGPASSWORD=secret TEMPLATES_AUTO_RELOAD=True gunicorn app:webapp --bind :5050 --reload
```
Open Firefox Browser and navigate to ...
* [Dashboard](http://localhost:5050/dashboard)
* [Blocks and Tx Errors](http://localhost:5050/recent-blocks)

3
app.py
View File

@ -1,9 +1,11 @@
from flask import Flask, render_template, request, make_response, redirect
from flask_sock import Sock
from turbo_flask import Turbo
import threading
import time
from flask_htmx import HTMX
import re
import flask
import transaction_database
import recent_blocks_database
@ -17,6 +19,7 @@ import config
webapp = Flask(__name__)
# https://blog.miguelgrinberg.com/post/dynamically-update-your-flask-web-pages-using-turbo-flask
turbo = Turbo(webapp)
sock = Sock(webapp)
htmx = HTMX(webapp)
webapp.update_thread_started = False