mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add scheduler.
This commit is contained in:
parent
0158f5bedc
commit
9679ef80c8
@ -1,3 +1,4 @@
|
|||||||
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
from config import config
|
from config import config
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_login import LoginManager
|
from flask_login import LoginManager
|
||||||
@ -6,11 +7,14 @@ from flask_sqlalchemy import SQLAlchemy
|
|||||||
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
mail = Mail()
|
|
||||||
|
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
login_manager.login_view = 'auth.login'
|
login_manager.login_view = 'auth.login'
|
||||||
|
|
||||||
|
mail = Mail()
|
||||||
|
|
||||||
|
background_scheduler = BackgroundScheduler()
|
||||||
|
|
||||||
|
|
||||||
def create_app(config_name):
|
def create_app(config_name):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -27,4 +31,9 @@ def create_app(config_name):
|
|||||||
from .main import main as main_blueprint
|
from .main import main as main_blueprint
|
||||||
app.register_blueprint(main_blueprint)
|
app.register_blueprint(main_blueprint)
|
||||||
|
|
||||||
|
from .scheduler import scheduler as scheduler_blueprint
|
||||||
|
app.register_blueprint(scheduler_blueprint, url_prefix='/scheduler')
|
||||||
|
|
||||||
|
background_scheduler.start()
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
5
app/scheduler/__init__.py
Normal file
5
app/scheduler/__init__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from flask import Blueprint
|
||||||
|
|
||||||
|
scheduler = Blueprint('scheduler', __name__)
|
||||||
|
|
||||||
|
from . import views
|
0
app/scheduler/forms.py
Normal file
0
app/scheduler/forms.py
Normal file
21
app/scheduler/views.py
Normal file
21
app/scheduler/views.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from flask import render_template
|
||||||
|
from . import scheduler
|
||||||
|
from flask_login import current_user, login_required
|
||||||
|
from .. import background_scheduler
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
@scheduler.route('/')
|
||||||
|
@login_required
|
||||||
|
def schedule():
|
||||||
|
job = {
|
||||||
|
'creator': current_user.id,
|
||||||
|
'files': ['file_1', 'file_2', 'file_3'],
|
||||||
|
'service': 'ocr',
|
||||||
|
'args': {
|
||||||
|
'lang': 'deu'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
job = background_scheduler.add_job(print, trigger='date', args=[job])
|
||||||
|
print(job)
|
||||||
|
return 'job'
|
Loading…
Reference in New Issue
Block a user