xppl/app/__init__.py
2018-06-07 10:46:14 +02:00

43 lines
1.4 KiB
Python
Executable File

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from marshmallow import Schema, fields, ValidationError, pre_load
from flask_socketio import SocketIO, emit
from os import environ
from dotenv import load_dotenv, find_dotenv
import os
import click
from werkzeug.utils import secure_filename
from sqlalchemy.dialects import registry
# import flask_whooshalchemyplus not using whoosh anymore
registry.register("rqlite.pyrqlite", "sqlalchemy_rqlite.pyrqlite", "dialect")
basedir = os.path.abspath(os.path.dirname(__file__))
UPLOAD_FOLDER = os.path.join(basedir, 'uploads')
UPLOAD_FOLDER_COVER = os.path.join(basedir, 'uploads/cover')
#ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
load_dotenv(find_dotenv())
app = Flask(__name__)
app.config['SECRET_KEY'] = 'super secret key'
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/mydatabase.db'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['SQLALCHEMY_DATABASE_URI'] = 'rqlite+pyrqlite://localhost:4001/'
app.config['DEBUG'] = True
app.config['PORT'] = 80
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'mydatabase.db')
db = SQLAlchemy(app)
DOMAIN = environ.get('DOMAIN')
socketio = SocketIO(app)
app.config.from_object(__name__)
from app import views
# set the location for the whoosh index
# app.config['WHOOSH_BASE'] = 'whoosh'
# flask_whooshalchemyplus.init_app(app) # initialize