From bfe28eca61c3b0b388c169469ba083af620159de Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Wed, 21 Aug 2019 14:41:38 +0200
Subject: [PATCH] Add socketio.
---
.flaskenv | 2 +-
app/__init__.py | 3 +++
opaque.py | 7 +++++--
requirements.txt | 2 ++
4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/.flaskenv b/.flaskenv
index f88b6e5b..30253e7c 100644
--- a/.flaskenv
+++ b/.flaskenv
@@ -1,2 +1,2 @@
-FLASK_APP=opaque.py
+#FLASK_APP=opaque.py
FLASK_ENV=development
diff --git a/app/__init__.py b/app/__init__.py
index 87d738e6..9d1e8207 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -3,6 +3,7 @@ from flask import Flask
from flask_apscheduler import APScheduler
from flask_login import LoginManager
from flask_mail import Mail
+from flask_socketio import SocketIO
from flask_sqlalchemy import SQLAlchemy
@@ -11,6 +12,7 @@ login_manager = LoginManager()
login_manager.login_view = 'auth.login'
mail = Mail()
scheduler = APScheduler()
+socketio = SocketIO()
def create_app(config_name):
@@ -23,6 +25,7 @@ def create_app(config_name):
mail.init_app(app)
scheduler.init_app(app)
scheduler.start()
+ socketio.init_app(app)
from .api import api as api_blueprint
app.register_blueprint(api_blueprint, url_prefix='/api')
diff --git a/opaque.py b/opaque.py
index 08ab588b..eb8ad4d2 100644
--- a/opaque.py
+++ b/opaque.py
@@ -1,13 +1,16 @@
-from app import create_app, db
+from app import create_app, db, socketio
from app.models import Corpus, User, Role, Permission, Job
from flask_migrate import Migrate
import os
-
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)
+if __name__ == '__main__':
+ socketio.run(app)
+
+
@app.shell_context_processor
def make_shell_context():
return dict(db=db,
diff --git a/requirements.txt b/requirements.txt
index 55c5be5e..55702c73 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,9 +1,11 @@
docker==4.0.2
+eventlet==0.25.0
Flask==1.0.3
Flask-APScheduler==1.11.0
Flask-Login==0.4.1
Flask-Mail==0.9.1
Flask-Migrate==2.5.2
+Flask-SocketIO==4.2.1
Flask-SQLAlchemy==2.4.0
Flask-Table==0.5.0
Flask-WTF==0.14.2