def setup(): try: db.connect() except OperationalError: pass
import datetime import json import os from flask import Flask, request from peewee import OperationalError from lib import issues, github, config from lib.database import db, create_tables, CrashKind, Crash, LogEntry app = Flask(__name__) db.connect() create_tables() db.close() @app.before_request def setup(): try: db.connect() except OperationalError: pass @app.teardown_request def stop(response): db.close() return response