Example #1
1
def create_app(db_name=None):
    app = Flask(__name__)
    app.config.from_object(config)
    if db_name:
        config.MONGO_DATABASE = db_name

    mongo, db = HapPyMongo(config)
    app.permanent_session_lifetime = timedelta(hours=2)

    auth = CloudAuth(app, db)
    app.context_processor(template_functions.view_functions)

    Admin(app)

    @app.before_first_request
    def logger():
        if not app.debug:
            app.logger.addHandler(logging.StreamHandler())
            app.logger.setLevel(logging.INFO)

    @app.before_request
    def before_request():
        g.db, g.auth = db, auth

    defaults.application_initialize(db, app)
    views.BaseView.register(app)
    views.GlobalManageView.register(app)
    views.QueryView.register(app)

    if db_name:
        return app, db
    else:
        return app
Example #2
1
    def start():
        """
        Start the application
        """
        config_type = "DevelopmentConfig"
        if len(sys.argv) == 2:
            if sys.argv[1] == "dev":
                config_type = "DevelopmentConfig"
            elif sys.argv[1] == "test":
                config_type = "TestConfig"
            elif sys.argv[1] == "prod":
                config_type = "ProductionConfig"
        app = Flask(__name__)
        app.config.from_object("conf.config.%s" % config_type)
        app.secret_key = getRandomInteger(128)
        app.permanent_session_lifetime = timedelta(seconds=10)
        FORMAT = "%(asctime)s %(levelname)s: " "%(message)s [in %(pathname)s:%(lineno)d]"
        logging.basicConfig(filename=app.config["LOGFILE"], level=logging.DEBUG, format=FORMAT)
        PYSTHClient.init_controllers(app)

        @app.errorhandler(400)
        def bad_request(exception):
            """Bad Request"""
            data = dict(status=exception.code, error=str(exception), description=bad_request.__doc__)
            return jsonify(data), 400

        @app.errorhandler(404)
        def page_not_found(exception):
            """Page Not Found"""
            data = dict(status=exception.code, error=str(exception), description=page_not_found.__doc__)
            return jsonify(data), 404

        if app.config["DEBUG"] is True:

            @app.errorhandler(500)
            def error(exception):
                """Internal Server Error"""
                data = dict(status=exception.code, error=str(exception), description=error.__doc__)
                return jsonify(data), 500

        @app.errorhandler(403)
        def forbidden(exception):
            """Forbidden"""
            data = dict(status=exception.code, error=str(exception), description=forbidden.__doc__)
            return jsonify(data), 403

        # noinspection PyUnusedLocal
        @app.before_first_request
        def bootstrap():
            """
            Call the bootstrap function
            """
            Bootstrap()

        with app.app_context():
            Base.do_first_request()
        app.run(app.config["HOST"], app.config["PORT"])
Example #3
0
def create_app(config_name):
    app = Flask(__name__)
    CORS(app)
    app.config.from_object(config[config_name])

    import logging
    from logging.handlers import RotatingFileHandler
    _handler = RotatingFileHandler(app.config['LOGGER_NAME'], maxBytes=10000, backupCount=1)
    _handler.setLevel(logging.DEBUG)
    app.logger.addHandler(_handler)

    pagedown.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    bootstrap.init_app(app)
    app.secret_key = app.config['SECRET_KEY']
    app.permanent_session_lifetime = timedelta(minutes=5)

    login_manager.init_app(app)
    db.init_app(app)
    from .api_1_0 import api as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api')
    from .base import base
    app.register_blueprint(base)
    from .rest_api import rest_api
    app.register_blueprint(rest_api, url_prefix='/rest')

    from .models import Role
    @app.before_first_request
    def build_up_before_start():
        Role.insert_roles()
    return app
def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].ASSET_PATH)

    init_app(
        application,
        configs[config_name],
        bootstrap=bootstrap,
        data_api_client=data_api_client,
        login_manager=login_manager
    )

    application.permanent_session_lifetime = timedelta(hours=1)
    from .main import main as main_blueprint
    from .status import status as status_blueprint

    url_prefix = application.config['URL_PREFIX']
    application.register_blueprint(status_blueprint, url_prefix=url_prefix)
    application.register_blueprint(main_blueprint, url_prefix=url_prefix)
    login_manager.login_view = 'main.render_login'
    main_blueprint.config = application.config.copy()

    init_frontend_app(application, data_api_client, login_manager)

    application.add_template_filter(parse_document_upload_time)

    @application.context_processor
    def extra_template_variables():
        return {
            'generic_contact_email': application.config['GENERIC_CONTACT_EMAIL'],
        }

    return application
Example #5
0
def create_app(config_filename='config.default.DevelopmentConfig'):
    app = Flask(__name__)
    app.config.from_object(config_filename)

    app.secret_key = app.config['SECRET_KEY']
    app.permanent_session_lifetime = timedelta(minutes=app.config['SESSION_ALIVE_MINUTES'])
    app.session_interface = ItsdangerousSessionInterface()
    # SOCKET
    # url = '127.0.0.1'
    # client_socket.connect((url, 8000))

    # logging module
    log_filepath = os.path.join(app.config['ROOT_DIR'], 'app_server/log')
    log.init(log_filepath=log_filepath, log_level=app.config['LOG_LEVEL'])
    log.info("CREATE HIMS APP : "+__name__)

    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)

    from youngs_server.api.auth_controllers import api_auth
    from youngs_server.api.member_controllers import api_member
    from youngs_server.api.lecture_controllers import api_lecture
    from youngs_server.api.question_controllers import api_question

    app.register_blueprint(api_auth)
    app.register_blueprint(api_member)
    app.register_blueprint(api_lecture)
    app.register_blueprint(api_question)
    return app
Example #6
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)
    bootstrap.init_app(app)
    # mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    admin.init_app(app)
    # Todo-rezwan follow this guide for auto renewing session
    # http://stackoverflow.com/questions/19760486/resetting-the-expiration-time-for-a-cookie-in-flask
    # http://stackoverflow.com/questions/19760486/resetting-the-expiration-time-for-a-cookie-in-flask
    app.permanent_session_lifetime = timedelta(minutes=60)  # adding session time out. working

    # attach routes and custom error pages here
    from main import main as main_blueprint
    app.register_blueprint(main_blueprint)
    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')
    from .admin import admin_panel as admin_blueprint
    app.register_blueprint(admin_blueprint, url_prefix='/admin')

    db.app = app
    db.create_all()


    return app
Example #7
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(app_config[config_name])
    app.permanent_session_lifetime = timedelta(minutes=5)
    init_models()
    register_blueprints(app)
    return app
def create_app(config_name):

    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].STATIC_URL_PATH)

    init_app(
        application,
        configs[config_name],
        bootstrap=bootstrap,
        data_api_client=data_api_client,
        feature_flags=feature_flags,
        login_manager=login_manager
    )
    # Should be incorporated into digitalmarketplace-utils as well
    csrf.init_app(application)

    application.permanent_session_lifetime = timedelta(hours=1)
    from .main import main as main_blueprint
    from .status import status as status_blueprint

    application.register_blueprint(status_blueprint, url_prefix='/admin')
    application.register_blueprint(main_blueprint, url_prefix='/admin')
    login_manager.login_view = 'main.render_login'
    main_blueprint.config = application.config.copy()

    @application.before_request
    def remove_trailing_slash():
        if request.path != '/' and request.path.endswith('/'):
            return redirect(request.path[:-1], code=301)

    application.add_template_filter(parse_document_upload_time)

    return application
Example #9
0
def create_app():
    application = Flask(__name__)
    application.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
    # application.config['BABEL_DEFAULT_LOCALE'] = 'ru-ru'
    application.config['SECRET_KEY'] = SECRET_KEY
    application.permanent_session_lifetime = timedelta(minutes=30)

    Triangle(application)
    assets.init_app(application)
    api.init_app(application)
    api.application = application
    db.init_app(application)
    admin.init_app(application)
    login_manager.init_app(application)
    application.db = db
    application.api = api

    babel = Babel(application)
    @babel.localeselector
    def get_locale():
        return request.accept_languages.best_match(["ru"])

    init_logging(application)

    return application
Example #10
0
    def flask(cls, name, config=None, debug=False, **kwargs):
        template_folder = kwargs.pop('template_folder', tmpl_dir)
        app = Flask(name, template_folder=template_folder, **kwargs)
        if config:
           app.config.from_object(config)
        app.permanent_session_lifetime = timedelta(minutes=60)
        app.debug = debug

        if app.config.get('COUCHDB_DATABASE',None) is None:
           app.config['COUCHDB_DATABASE'] = name.lower()

        assert app.secret_key is not None, "flask config does not specify a secret key"
        return app
Example #11
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object('config')
    bootstrap.init_app(app)
    # moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    app.permanent_session_lifetime = timedelta(hours=24)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    return app
Example #12
0
def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'THIS IS JUST A TEST WEBPAGE !'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:R0boo@Sip$@127.0.0.1/maizi'
    app.config['BABEL_DEFAULT_LOCALE'] = 'en'
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    from flask.json import JSONEncoder

    class CustomJSONEncoder(JSONEncoder):
        """This class adds support for lazy translation texts to Flask's
        JSON encoder. This is necessary when flashing translated texts."""

        def default(self, obj):
            from speaklater import is_lazy_string
            if is_lazy_string(obj):
                try:
                    return unicode(obj)  # python 2
                except NameError:
                    return str(obj)  # python 3
            return super(CustomJSONEncoder, self).default(obj)

    app.json_encoder = CustomJSONEncoder

    bootstrap.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    pagedown.init_app(app)
    Gravatar(app, size=64)
    babel.init_app(app)

    from auth import auth as auth_blueprint
    from main import main as main_blueprint
    app.register_blueprint(auth_blueprint)
    app.register_blueprint(main_blueprint)

    app.permanent_session_lifetime = timedelta(minutes=5)

    @app.template_test('current_link')
    def is_current_link(link):
        return link == request.path

    @babel.localeselector
    def get_locale():
        return current_user.locale

    return app
Example #13
0
def create_app(config_name):
    application = Flask(
        __name__,
        static_folder='static/',
        static_url_path=configs[config_name].STATIC_URL_PATH
    )

    application.config['NOTIFY_ENVIRONMENT'] = config_name
    application.config.from_object(configs[config_name])

    init_app(application)
    csrf.init_app(application)

    @csrf.error_handler
    def csrf_handler(reason):
        if 'user_id' not in session:
            application.logger.info(
                u'csrf.session_expired: Redirecting user to log in page'
            )

            return application.login_manager.unauthorized()

        application.logger.info(
            u'csrf.invalid_token: Aborting request, user_id: {user_id}',
            extra={'user_id': session['user_id']})

        abort(400, reason)

    login_manager.init_app(application)
    admin_api_client.init_app(application)
    proxy_fix.init_app(application)

    from .main import main as main_blueprint
    application.permanent_session_lifetime = timedelta(hours=1)
    application.register_blueprint(main_blueprint, url_prefix='/admin')
    login_manager.login_view = 'main.render_login'

    main_blueprint.config = application.config.copy()

    @application.before_request
    def remove_trailing_slash():
        if request.path != '/' and request.path.endswith('/'):
            return redirect(request.path[:-1], code=301)

    application.add_template_filter(datetimeformat)

    return application
def create_manager(deed_api_client=make_deed_api_client()):
    app = Flask(__name__)
    app.config.from_pyfile('config.py')

    manager = Manager(app)
    app.url_map.strict_slashes = False

    setattr(searchdeed, 'deed_api_client', deed_api_client)

    app.register_blueprint(health, url_prefix='/health')
    app.register_blueprint(searchdeed)
    app.register_blueprint(borrower_landing)
    app.secret_key = app.config['APP_SECRET_KEY']

    app.permanent_session_lifetime = timedelta(minutes=20)

    return manager
Example #15
0
def create_app(config_name):
    app = Flask(__name__)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    app.config.from_object(config[config_name])
    app.permanent_session_lifetime = timedelta(minutes=5)

    config[config_name].init_app(app)
    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)

    # 附加路由和自定义的错误页面
    return app
Example #16
0
def create_app(config_name):
	app = Flask(__name__)
	app.config.from_object(config[config_name])
	app.permanent_session_lifetime = timedelta(minutes = 10)
	config[config_name].init_app(app)
	mail.init_app(app)
	moment.init_app(app)
	db.init_app(app)

	# attach routes and custom error pages here

	from main import main as main_blueprint
	app.register_blueprint(main_blueprint)


	file_handler = RotatingFileHandler('logs/nights_watch.log',
		'a',									# Append
		1 * 1024 * 1024 * 1024,					# 10 MB
		20)										# Max 20 log files
	
	#mail_handler = SMTPHandler(
	#	mailhost=(app.config["MAIL_SERVER"], app.config["MAIL_PORT"]),
	#	fromaddr=app.config["MAIL_SENDER"],
	#	toaddrs=app.config["MAIL_TO"],
	#	subject=app.config["MAIL_SUBJECT_PREFIX"])

	log_format_file = logging.Formatter('%(asctime)s %(levelname)s: %(message)s \
	[at %(pathname)s:%(lineno)d]')

	#log_format_email = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')

	file_handler.setFormatter(log_format_file)
	#mail_handler.setFormatter(log_format_email)

	app.logger.setLevel(logging.INFO)

	file_handler.setLevel(logging.INFO)
	#mail_handler.setLevel(logging.WARNING)

	app.logger.addHandler(file_handler)
	#app.logger.addHandler(mail_handler)

	app.logger.info('application started!!!')

	return app
    def setUp(self):
        application = Flask(__name__)
        application.config['TESTING'] = True
        application.secret_key = 'you will not guess'
        application.permanent_session_lifetime = timedelta(seconds=1)

        login_manager.init_app(application)
        self.application = application
        with self.application.test_client() as c:
            with c.session_transaction() as sess:
                sess['user_id'] = '1'

        schema_file = open(os.path.join(settings.EQ_SCHEMA_DIRECTORY, "0_star_wars.json"))
        schema = schema_file.read()
        # create a parser
        self.schema_json = json.loads(schema)
        parser = SchemaParserFactory.create_parser(self.schema_json)
        self.questionnaire = parser.parse()
def create_app(config_name):

    application = Flask(__name__, static_folder="static/", static_url_path=configs[config_name].STATIC_URL_PATH)

    init_app(
        application,
        configs[config_name],
        bootstrap=bootstrap,
        data_api_client=data_api_client,
        feature_flags=feature_flags,
        login_manager=login_manager,
    )
    # Should be incorporated into digitalmarketplace-utils as well
    csrf.init_app(application)

    application.permanent_session_lifetime = timedelta(hours=1)
    from .main import main as main_blueprint
    from .status import status as status_blueprint

    application.register_blueprint(status_blueprint, url_prefix="/admin")
    application.register_blueprint(main_blueprint, url_prefix="/admin")
    login_manager.login_view = "main.render_login"
    main_blueprint.config = application.config.copy()

    @application.before_request
    def remove_trailing_slash():
        if request.path != "/" and request.path.endswith("/"):
            return redirect(request.path[:-1], code=301)

    @application.template_filter("timeformat")
    def timeformat(value):
        return datetime.strptime(value, formats.DATETIME_FORMAT).strftime(DISPLAY_TIME_FORMAT)

    @application.template_filter("dateformat")
    def dateformat(value):
        return datetime.strptime(value, formats.DATETIME_FORMAT).strftime(DISPLAY_DATE_FORMAT)

    @application.template_filter("displaydateformat")
    def display_date_format(value):
        return value.strftime(DISPLAY_DATE_FORMAT)

    return application
Example #19
0
def create_app(config_name):
    app = Flask(__name__)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    app.config.from_object(config[config_name])
    app.permanent_session_lifetime = timedelta(minutes=5)

    config[config_name].init_app(app)
    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)

    return app
Example #20
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    db.init_app(app)
    bootstrap.init_app(app)
    mail.init_app(app)
    login_manager.init_app(app)

    # security setting
    app.secret_key="youdon'tknwhatIT1s"
    app.permanent_session_lifetime = datetime.timedelta(minutes=30)

    # register blueprint
    from .main import main as main_blueprint

    app.register_blueprint(main_blueprint)

    return app
Example #21
0
def create_app(db_name=None):
    app = Flask(__name__)
    app.config.from_object(config)
    if db_name:
        config.MONGO_DATABASE = db_name

    Admin(app)
    Engine(app)
    mongo, db = HapPyMongo(config)
    app.permanent_session_lifetime = timedelta(hours=2)
    auth = CloudAuth(app, db)

    custom_filters = {
        name: function for name, function in getmembers(template_filters)
        if isfunction(function)
    }
    app.jinja_env.filters.update(custom_filters)
    app.context_processor(template_functions.utility_processor)

    @app.before_first_request
    def logger():
        if not app.debug:
            app.logger.addHandler(logging.StreamHandler())
            app.logger.setLevel(logging.INFO)

    @app.before_request
    def before_request():
        g.db, g.auth = db, auth

    defaults.application_initialize(db, app)
    views.ProductsView.register(app)
    views.MiscView.register(app)
    views.FeedbackView.register(app)
    views.GlobalManageView.register(app)

    if db_name:
        return app, db
    else:
        return app
def create_app(config=config.dev_config, school_name=None):
	""" The main entry point where the application is created """
	# Create the application
	app = Flask(__name__)    
    # User only logged in for 10 minutes before getting auto logged out
	app.permanent_session_lifetime = timedelta(seconds=600)
	# Default configurations
	app.config.from_object(config)
	# Configuration overrides
	app.config.from_pyfile('../application.cfg', silent=True)
	# In "multi-school" mode, each school is run as a separate app.
	# And each is run under the root directory (eg. domain.net/school)
	if school_name is not None:
		app.config['SCRIPT_NAME'] = '/'+school_name
	app.config['SCHOOL'] = school_name or app.config['DEFAULT_SCHOOL']

	# Register everything
	register_extensions(app)
	register_views(app)
	register_template_filters(app)
	configure_hooks(app)
	return app
def create_app(config_name):
    application = Flask(__name__,
                        static_folder='static/',
                        static_url_path=configs[config_name].STATIC_URL_PATH)

    init_app(
        application,
        configs[config_name],
        data_api_client=data_api_client,
        feature_flags=feature_flags,
        login_manager=login_manager,
    )
    application.permanent_session_lifetime = timedelta(hours=1)
    from .main import main as main_blueprint
    from .status import status as status_blueprint

    application.register_blueprint(status_blueprint,
                                   url_prefix='/suppliers')
    application.register_blueprint(main_blueprint,
                                   url_prefix='/suppliers')
    login_manager.login_view = 'main.render_login'
    main_blueprint.config = application.config.copy()

    csrf.init_app(application)

    @application.before_request
    def remove_trailing_slash():
        if request.path.endswith('/'):
            return redirect(request.path[:-1], code=301)

    @application.before_request
    def refresh_session():
        session.permanent = True
        session.modified = True

    return application
Example #24
0
File: app.py Project: iluddy/flock
from flask import got_request_exception
from celery import Celery
import __builtin__

# Argument parser
arg_parser = argparse.ArgumentParser()
arg_parser.add_argument("-c")
args = arg_parser.parse_args()

# Config
cfg = read_config_file(args.c)

# Create App
app = Flask(__name__, static_url_path='')
app.secret_key = SECRET_KEY
app.permanent_session_lifetime = SESSION_DURATION
documentor = Autodoc(app)
app.config['MONGODB_SETTINGS'] = {
    'db': cfg["database"]["name"],
    'host': cfg["database"]["host"],
    'port': cfg["database"]["port"]
}

# Celery
app.config['CELERY_BROKER_URL'] = cfg['redis']['url']
app.config['CELERY_RESULT_BACKEND'] = cfg['redis']['url']

def make_celery(app):
    celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
Example #25
0
                    tree['children'].append(dict(name=fn.replace(
                        os.getcwd() + os.path.sep, "")))

    return tree


def d2d_close_instance(uid):

    while True:
        try:
            if d2d_instances[uid]['alive'] == 0:
                # clean up the global dicts, deletes the instances
                del(d2d_instances[uid])
                break

            d2d_instances[uid]['alive'] = 0
            time.sleep(SESSION_LIFETIME)
        except:
            print('Unable to shutdown thread ' + str(uid))
            break

if __name__ == "__main__":
    app.secret_key = os.urandom(24)
    app.permanent_session_lifetime = SESSION_LIFETIME
    app.debug = DEBUG
    app.json_encoder = plotly.utils.PlotlyJSONEncoder
    app.run(threaded=True,
            host="127.0.0.1",
            port=int("5000")
            )
Example #26
0
#"moron", "idiot", "fool"
#]

# The ideal tsundere greeting is cold and hostile while betraying a
# lingering sense of affection. Constantly search for it.

# Set up Flask app
app = Flask(__name__)

# Database URL, or sqlite in-memory database
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL')
# Secret key (for sessions/cookies)
app.secret_key = os.environ.get('SECRET_KEY') or 'yolodesu'

# Sessions last for 100 years
app.permanent_session_lifetime = timedelta(days=36500)

# Import the rest of the tsundiary stuff
from tsundiary.views import *
from tsundiary.models import User, db
from tsundiary.utils import their_date
import tsundiary.jinja_env

migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)

############
# App funcs

@app.before_request
Example #27
0
# -*- coding: utf-8 -*-
from flask import Flask,redirect,url_for,render_template,session,request
import os
import threading
import subprocess
import sys
from datetime import timedelta

app = Flask(__name__)
app.secret_key = os.urandom(24)
#session.permanent = True
app.permanent_session_lifetime = timedelta(minutes=30)

#消息循环队列初始化
cache_msg=['']*30
cache_msg_num=0

#配置初始化
try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET
configxml = ET.ElementTree(file='rmcsconfig.xml')
mcargs = configxml.find('mcargs').text
javaexe = configxml.find('javaexe').text
expires = configxml.find('expires').text

#启动进程
p = subprocess.Popen(mcargs, executable=javaexe, universal_newlines=True, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = False)

Example #28
0
import sys
from datetime import timedelta
from flask import Flask
from Config import ProductionConfig
from views.lib import Conn
import os

app = Flask(__name__)
app.secret_key = os.environ.get('SECRET_KEY') or os.urandom(64)
app.config.from_object(ProductionConfig)
Mongo = Conn.MongoDB(app.config.get('DB'), app.config.get('PORT'), app.config.get('DBNAME'),
                     app.config.get('DBUSERNAME'), app.config.get('DBPASSWORD'))
app.permanent_session_lifetime = timedelta(hours=6)
page_size = 60
sys.path.append(sys.path[0] + '/vulscan/vuldb/')
file_path = os.path.split(os.path.realpath(__file__))[0] + '/../vulscan/vuldb/'
Example #29
0
# log.setLevel(logging.DEBUG)
# log.addHandler(handler)

app.cache = redis.StrictRedis(**app.config.get('REDIS_CONFIG'))

app.cache.set("saDir", SA_DIR)
app.cache.set("uid_track", 1)
app.cache.set("session_data", {})

app.config['UPLOAD_FOLDER'] = os.path.dirname(os.path.abspath(__file__)) + SA_DIR
app.config['STATIC_FOLDER'] = os.path.dirname(os.path.abspath(__file__)) + '/static'

# app.session_interface = RedisSessionInterface(app.cache, key_prefix='SESSION')
app.session_interface = RedisSessionInterface(app.cache, key_prefix='SESSION',
                                            use_signer=True, permanent=False)
app.permanent_session_lifetime = datetime.timedelta(hours=1)

try:
    os.mkdir(SA_DIR)
except Exception as E:
    app.logger.info("[%s] mkdir() -- [%s] : %s" % \
                        (ctime(), SA_DIR, E))

# def reset_cache(sessionID):
#     session_data = {
#         "false_upload": True,
#         # "stdOut": '',
#         # "stdOut_conv": ''
#     }
#     app.cache.hmset("session_data:%s" % sessionID, session_data)
Example #30
0
"""
app.config['MAIL_SERVER'] = ""
app.config['MAIL_PORT'] = ""
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_USERNAME'] = 'test@test.com'
app.config['MAIL_PASSWORD'] = 'testpw' 

app.config['SQLALCHEMY_DATABASE_URI'] =\
	'sqlite:///' + os.path.join (basedir, 'data.sqlite')
#app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']
#uncomment this line if you want to use Heroku, comment instead the one before it
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

app.config['UPLOAD_FOLDER'] = './static/balls'

app.permanent_session_lifetime = timedelta(seconds=60)
app.config['SECRET_KEY'] = 'veryhard2guess'
#be more original

FTP_USER = '222'
FTP_PASS = '333'
FTP_HOST = 'ftp.ftp.com'
#again, environmental variables are preferred
manager = Manager(app)
bootstrap = Bootstrap(app)
db = SQLAlchemy(app)
mail = Mail(app)
db.drop_all()


login_manager = LoginManager()