config.py 1.06 KB
Newer Older
Michal Pavlík's avatar
Michal Pavlík committed
1 2
import connexion
from flask_sqlalchemy import SQLAlchemy
Michal Pavlík's avatar
Michal Pavlík committed
3
from errors import ProjectException
Michal Pavlík's avatar
Michal Pavlík committed
4 5 6 7 8 9

cnx = connexion.App(__name__, specification_dir='./')

db = SQLAlchemy()
db.init_app(cnx.app)

Michal Pavlík's avatar
Michal Pavlík committed
10 11 12 13
cnx.app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///./data.db'
cnx.app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
cnx.app.config["SQLALCHEMY_ECHO"] = True
cnx.app.config['MAX_CONTENT_LENGTH'] = 2 * 1024 * 1024
Michal Pavlík's avatar
Michal Pavlík committed
14

Michal Pavlík's avatar
Michal Pavlík committed
15
ALLOWED_IMAGE_FILES = ['png', 'jpg', 'jpeg']
Michal Pavlík's avatar
Michal Pavlík committed
16

Michal Pavlík's avatar
Michal Pavlík committed
17 18 19 20 21
PUBLIC_KEY = b"""-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAza5xftTPKTpef9sXgaJD41veGVeSshAEdaK/iRHHVVOsgVxEGxQl6UfCe1CTUV8Xq4NLISk5chNdMHDJBOlyXIc0xuA3F48kEMRKEuVAug9AruEF4xTX87Ya3B5sL38nLF+SkExKLz+05C/JERAsHE00eP3+/UkRIx2Zv+hWC3+bMv9uK6QmGoCBy9829TzDsdRaPFzj9DTTT44K9Ko/KugffnB5kgI49SUSqo/hyohCEZN0Abbho9f38tXNV4d+9dantkbUCNNmj3zGiYbzxBjEokxIMUn2N/57ys9ZhNllLEy5eSAoOF6hp1I0vN8c9uGbAmA0h1TJutsP6f5tEQIDAQAB
-----END PUBLIC KEY-----"""

@cnx.app.errorhandler(ProjectException)
Michal Pavlík's avatar
Michal Pavlík committed
22 23 24 25 26
def exception_handler(e):
    return {
        'msg': e.get_message(),
        'code': e.get_code()
    }, e.get_http_code()