mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-01 10:20:34 +00:00
declutter by using default filenames
This commit is contained in:
59
wsgi.py
Normal file
59
wsgi.py
Normal file
@ -0,0 +1,59 @@
|
||||
# First things first: apply monkey patch, so that no code gets executed without
|
||||
# patched libraries!
|
||||
import eventlet
|
||||
eventlet.monkey_patch()
|
||||
|
||||
from app import create_app, db, scheduler, socketio # noqa
|
||||
from app.models import (
|
||||
Avatar,
|
||||
Corpus,
|
||||
CorpusFile,
|
||||
CorpusFollowerAssociation,
|
||||
CorpusFollowerRole,
|
||||
Job,
|
||||
JobInput,
|
||||
JobResult,
|
||||
Role,
|
||||
TesseractOCRPipelineModel,
|
||||
SpaCyNLPPipelineModel,
|
||||
User
|
||||
) # noqa
|
||||
from flask import Flask # noqa
|
||||
from typing import Any, Dict # noqa
|
||||
|
||||
|
||||
app: Flask = create_app()
|
||||
|
||||
|
||||
@app.shell_context_processor
|
||||
def make_shell_context() -> Dict[str, Any]:
|
||||
''' Adds variables to the shell context. '''
|
||||
return {
|
||||
'db': db,
|
||||
'Avatar': Avatar,
|
||||
'Corpus': Corpus,
|
||||
'CorpusFile': CorpusFile,
|
||||
'CorpusFollowerAssociation': CorpusFollowerAssociation,
|
||||
'CorpusFollowerRole': CorpusFollowerRole,
|
||||
'Job': Job,
|
||||
'JobInput': JobInput,
|
||||
'JobResult': JobResult,
|
||||
'Role': Role,
|
||||
'TesseractOCRPipelineModel': TesseractOCRPipelineModel,
|
||||
'SpaCyNLPPipelineModel': SpaCyNLPPipelineModel,
|
||||
'User': User
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
with app.app_context():
|
||||
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
|
||||
for corpus in Corpus.query.filter(Corpus.num_analysis_sessions > 0).all():
|
||||
corpus.num_analysis_sessions = 0
|
||||
db.session.commit()
|
||||
scheduler.start()
|
||||
socketio.run(app, host='0.0.0.0')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Reference in New Issue
Block a user