nopaque/wsgi.py

45 lines
1.2 KiB
Python
Raw Normal View History

# First things first: apply monkey patch, so that no code gets executed without
# patched libraries!
2019-08-26 12:21:06 +00:00
import eventlet
eventlet.monkey_patch()
2021-12-07 13:18:05 +00:00
from flask import Flask # noqa
from typing import Any, Dict # noqa
from app import create_app, db, scheduler, socketio # noqa
from app import models # noqa
2019-07-03 08:31:23 +00:00
2021-12-07 13:18:05 +00:00
app: Flask = create_app()
@app.shell_context_processor
2021-12-07 13:18:05 +00:00
def make_shell_context() -> Dict[str, Any]:
''' Adds variables to the shell context. '''
return {
2023-02-23 12:05:04 +00:00
'db': db,
'Avatar': models.Avatar,
'Corpus': models.Corpus,
'CorpusFile': models.CorpusFile,
'CorpusFollowerAssociation': models.CorpusFollowerAssociation,
'CorpusFollowerRole': models.CorpusFollowerRole,
'Job': models.Job,
'JobInput': models.JobInput,
'JobResult': models.JobResult,
'Role': models.Role,
'TesseractOCRPipelineModel': models.TesseractOCRPipelineModel,
'SpaCyNLPPipelineModel': models.SpaCyNLPPipelineModel,
'User': models.User
2021-12-07 13:18:05 +00:00
}
def main():
2024-08-01 10:10:33 +00:00
if app.config['NOPAQUE_IS_PRIMARY_INSTANCE']:
with app.app_context():
scheduler.start()
socketio.run(app, host='0.0.0.0')
if __name__ == '__main__':
main()