Exemple #1
0
 def init_db(self):
     try:
         from flask_sqlalchemy import SQLAlchemy
         from powerhub.sql import init_db
         db = SQLAlchemy(self.flask_app)
         init_db(db)
     except ImportError as e:
         log.error("You have unmet dependencies, "
                   "database will not be available")
         log.exception(e)
         db = None
     self.db = db
Exemple #2
0
from powerhub.logging import log
from powerhub._version import __version__

app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1, x_port=1)
app.config.update(
    DEBUG=args.DEBUG,
    SECRET_KEY=os.urandom(16),
    SQLALCHEMY_DATABASE_URI='sqlite:///' + DB_FILENAME,
    SQLALCHEMY_TRACK_MODIFICATIONS=False,
)

try:
    from flask_sqlalchemy import SQLAlchemy
    db = SQLAlchemy(app)
    init_db(db)
except ImportError as e:
    log.error("You have unmet dependencies, database will not be available")
    log.exception(e)
    db = None
cb = get_clipboard()

socketio = SocketIO(
    app,
    async_mode="threading",
    cors_allowed_origins=[
        "http://%s:%d" % (
            args.URI_HOST,
            args.LPORT,
        ),
        "https://%s:%d" % (