def main(create_app_func=None): if not create_app_func: from widukind_web.wsgi import create_app create_app_func = create_app class ServerWithGevent(Server): help = description = 'Runs the Flask development server with Gevent WSGI Server' def __call__(self, app, host, port, use_debugger, use_reloader, threaded, processes, passthrough_errors): if use_debugger: app = DebuggedApplication(app, evalex=True) server = WSGIServer((host, port), app) try: print('Listening on http://%s:%s' % (host, port)) server.serve_forever() except KeyboardInterrupt: pass env_config = config_from_env('WIDUKIND_SETTINGS', 'widukind_web.settings.Prod') manager = Manager(create_app_func, with_default_commands=False) #TODO: option de config app pour désactiver run counter manager.add_option('-c', '--config', dest="config", default=env_config) manager.add_command("shell", Shell()) if HAS_GEVENT: manager.add_command("server", ServerWithGevent( host = '0.0.0.0', port=8081) ) else: manager.add_command("server", Server( host = '0.0.0.0', port=8081) ) manager.add_command("config", ShowConfigCommand()) manager.add_command("urls", ShowUrlsCommand()) manager.add_command("assets", ManageAssets()) manager.run()
def _create_superadmin_user(**kwargs): user = models.User.create_user( username=config_from_env('MMW_SUPERADMIN_EMAIL', '*****@*****.**'), password=config_from_env('MMW_SUPERADMIN_PASSWORD', 'password'), role='superadmin', group=constants.GROUP_DEFAULT)
def reset(): models.User.drop_collection() models.User.create_user( username=config_from_env('MMW_SUPERADMIN_EMAIL', '*****@*****.**'), password=config_from_env('MMW_SUPERADMIN_PASSWORD', 'password'), role="superadmin", group=constants.GROUP_DEFAULT) for i in xrange(1, 10): models.Domain.objects.get_or_create(name="example-%s.net" % i) models.Mynetwork.objects.get_or_create(ip_address="10.0.0.%d" % i)
def _conf_social(app): socials_found = {} GITHUB_KEY = config_from_env('SHORTURL_SOCIAL_GITHUB_KEY', None) GITHUB_SECRET = config_from_env('SHORTURL_SOCIAL_GITHUB_SECRET', None) if GITHUB_KEY and GITHUB_SECRET: socials_found["flask_social_blueprint.providers.Github"] = { 'consumer_key': GITHUB_KEY, 'consumer_secret': GITHUB_SECRET } app.config['SOCIAL_BLUEPRINT'] = socials_found
def create_app(config='shortener_url.settings.Prod'): env_config = config_from_env('SHORTURL_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) app.config['LOGGER_NAME'] = 'shortener_url' app._logger = _conf_logging(debug=app.debug, prog_name='shortener_url') if app.config.get("LOGGING_MAIL_ENABLE", False): _conf_logging_mail(app) _conf_sentry(app) _conf_jsonify(app) _conf_errors(app) _conf_compress(app) _conf_assets(app) _conf_babel(app) _conf_bootstrap(app) _conf_default_views(app) _conf_social(app) settings, storage = utils.get_db_config(**app.config.get('DB_SETTINGS')) if storage == "mongo": app.config['STORAGE'] = "mongo" if 'DEBUG_TB_PANELS' in app.config: app.config['DEBUG_TB_PANELS'].append('flask.ext.mongoengine.panels.MongoDebugPanel') _conf_storage_mongo(app, settings) _conf_admin_mongo(app) _conf_security_mongo(app) _conf_session_mongo(app) elif storage == "sql": app.config['STORAGE'] = "sql" _conf_storage_peewee(app, settings) _conf_admin_peewee(app) _conf_security_peewee(app) _conf_session_peewee(app) _conf_bp(app) _conf_moment(app) _conf_mail(app) _conf_cors(app) app.wsgi_app = ProxyFix(app.wsgi_app) return app
def create_app(config='widukind_web.settings.Prod', db=None): env_config = config_from_env('WIDUKIND_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) _conf_db(app, db=db) app.config['LOGGER_NAME'] = 'widukind_web' app._logger = _conf_logging(debug=app.debug, prog_name='widukind_web') if app.config.get("LOGGING_MONGO_ENABLE", True): _conf_logging_mongo(app) if app.config.get("LOGGING_MAIL_ENABLE", False): _conf_logging_mail(app) _conf_logging_errors(app) extensions.moment.init_app(app) _conf_bootstrap(app) _conf_sentry(app) _conf_errors(app) _conf_cache(app) _conf_converters(app) _conf_jsonify(app) _conf_default_views(app) _conf_bp(app) _conf_record_query(app) _conf_processors(app) _conf_periods(app) _conf_auth(app) _conf_sitemap(app) _conf_session(app) _conf_mail(app) _conf_assets(app) app.wsgi_app = ProxyFix(app.wsgi_app) return app
def create_app(config='widukind_web.settings.Prod', db=None): env_config = config_from_env('WIDUKIND_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) _conf_db(app, db=db) app.config['LOGGER_NAME'] = 'widukind_web' app._logger = _conf_logging(debug=app.debug, prog_name='widukind_web') if app.config.get("LOGGING_MONGO_ENABLE", True): _conf_logging_mongo(app) if app.config.get("LOGGING_MAIL_ENABLE", False): _conf_logging_mail(app) _conf_logging_errors(app) extensions.moment.init_app(app) _conf_bootstrap(app) _conf_sentry(app) # _conf_errors(app) _conf_cache(app) _conf_converters(app) _conf_jsonify(app) _conf_default_views(app) _conf_bp(app) _conf_record_query(app) _conf_processors(app) _conf_periods(app) _conf_auth(app) _conf_sitemap(app) _conf_session(app) _conf_mail(app) _conf_assets(app) app.wsgi_app = ProxyFix(app.wsgi_app) return app
def create_app(config='mongrey.web.settings.Prod'): env_config = config_from_env('MONGREY_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) if not app.config.get('TESTING', False): app.config['LOGGER_NAME'] = 'mongrey' app._logger = utils.configure_logging(debug=app.debug, prog_name='mongrey') utils.SECRET_KEY = app.config.get('SECRET_KEY') _configure_i18n(app) login_manager.init_app(app) settings, storage = utils.get_db_config(**app.config.get('DB_SETTINGS')) if storage == "mongo": _configure_storage_mongo(app) app.config['STORAGE'] = "mongo" if 'DEBUG_TB_PANELS' in app.config: app.config['DEBUG_TB_PANELS'].append('flask.ext.mongoengine.panels.MongoDebugPanel') elif storage == "sql": _configure_storage_sql(app) app.config['STORAGE'] = "sql" _configure_session(app) _configure_sentry(app) if app.debug: try: from flask_debugtoolbar import DebugToolbarExtension DebugToolbarExtension(app) except ImportError: pass @app.context_processor def all_processors(): current_lang = session.get(constants.SESSION_LANG_KEY, app.config.get('BABEL_DEFAULT_LOCALE')) return dict(current_theme=app.config.get('DEFAULT_THEME', 'slate'), current_lang=current_lang, langs=app.config.get('ACCEPT_LANGUAGES_CHOICES'), url_for_security=app.login_app.url_for_security, is_hidden=forms._is_hidden, is_required=forms._is_required, ) app.wsgi_app = ProxyFix(app.wsgi_app) return app
def main(create_app_func=None): if not create_app_func: from mongrey.web.wsgi import create_app create_app_func = create_app class ServerWithGevent(Server): help = description = 'Runs the Flask server with Gevent WSGI' def __call__(self, app, host=None, port=None, use_debugger=None, use_reloader=None, threaded=False, processes=1, passthrough_errors=False): config = app.config logger = app.logger if use_debugger: app = DebuggedApplication(app, evalex=True) host = config.get('WEB_HOST', host) port = config.get('WEB_PORT', port) security_by_host = config.get('SECURITY_BY_HOST', False) allow_hosts = config.get('ALLOW_HOSTS', []) server = SecureWSGIServer((host, port), application=app, security_by_host=security_by_host, allow_hosts=allow_hosts, #log=GeventAccessLogger(logger) ) try: logger.info('Listening on http://%s:%s' % (host, port)) server.serve_forever() except KeyboardInterrupt: pass env_config = config_from_env('MONGREY_SETTINGS', 'mongrey.web.settings.Prod') manager = Manager(create_app_func, with_default_commands=False) manager.add_option('-c', '--config', dest="config", default=env_config) manager.add_command("shell", Shell()) manager.add_command("server", ServerWithGevent()) manager.add_command("config", ShowConfigCommand()) manager.add_command("urls", ShowUrlsCommand()) manager.add_command("default-user", CreateDefaultUserCommand()) manager.add_command("import-whitelist", ImportWhiteList()) manager.run()
def main(create_app_func=None): """ TODO: commands pour créer fixtures de chaque mode pour démo """ if not create_app_func: from mongo_mail_web.wsgi import create_app create_app_func = create_app class ServerWithGevent(Server): help = description = 'Runs the Flask development server with WSGI SocketIO Server' def __call__(self, app, host, port, use_debugger, use_reloader, threaded, processes, passthrough_errors): #console_path='/console' if use_debugger: app = DebuggedApplication(app, evalex=True) """ TODO: from policyng_web.clients import tasks tasks.start_all(app) """ server = WSGIServer((host, port), app) try: print 'Listening on http://%s:%s' % (host, port) server.serve_forever() except KeyboardInterrupt: pass env_config = config_from_env('MMW_SETTINGS', 'mongo_mail_web.settings.Prod') manager = Manager(create_app_func, with_default_commands=False) manager.add_option('-c', '--config', dest="config", default=env_config) manager.add_command("shell", Shell()) manager.add_command("server", ServerWithGevent( host = '0.0.0.0', port=8081) ) manager.add_command("config", ShowConfigCommand()) manager.add_command("urls", ShowUrlsCommand()) manager.add_command("reset-db", ResetCommand()) manager.add_command("reset-metrics", ResetMetrics()) manager.add_command('users', ShowUsersCommand()) manager.add_command('create-superadmin', CreateSuperAdminCommand()) manager.run()
def create_app(config='mongo_mail_web.settings.Prod'): """ TODO: before first request pour redirect vers form domains/mynetwork si aucun """ env_config = config_from_env('MMW_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) if PYMONGO2: app.config['MONGODB_SETTINGS']['use_greenlets'] = True app.config['LOGGER_NAME'] = 'mongo_mail_web' app._logger = _configure_logging(debug=app.debug, prog_name='mongo_mail_web') extensions.db.init_app(app) _configure_mongolock(app) extensions.moment.init_app(app) _configure_i18n(app) _configure_security(app) admin.init_admin(app, url='/') _configure_processors(app) _configure_themes(app) geoip_tools.configure_geoip() if app.debug: from flask_debugtoolbar import DebugToolbarExtension DebugToolbarExtension(app) _configure_sentry(app) if app.config.get('SESSION_ENGINE_ENABLE', False): from flask_mongoengine import MongoEngineSessionInterface app.session_interface = MongoEngineSessionInterface(extensions.db) error_handlers(app) app.wsgi_app = ProxyFix(app.wsgi_app) tasks.run_all_tasks( completed_pool=app.config.get('TASK_COMPLETED_POOL'), completed_sleep=app.config.get('TASK_COMPLETED_SLEEP'), update_metrics_sleep=app.config.get('TASK_UPDATE_METRICS_SLEEP')) return app
def create_app(config='mongo_mail_web.settings.Prod'): """ TODO: before first request pour redirect vers form domains/mynetwork si aucun """ env_config = config_from_env('MMW_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) if PYMONGO2: app.config['MONGODB_SETTINGS']['use_greenlets'] = True app.config['LOGGER_NAME'] = 'mongo_mail_web' app._logger = _configure_logging(debug=app.debug, prog_name='mongo_mail_web') extensions.db.init_app(app) _configure_mongolock(app) extensions.moment.init_app(app) _configure_i18n(app) _configure_security(app) admin.init_admin(app, url='/') _configure_processors(app) _configure_themes(app) geoip_tools.configure_geoip() if app.debug: from flask_debugtoolbar import DebugToolbarExtension DebugToolbarExtension(app) _configure_sentry(app) if app.config.get('SESSION_ENGINE_ENABLE', False): from flask_mongoengine import MongoEngineSessionInterface app.session_interface = MongoEngineSessionInterface(extensions.db) error_handlers(app) app.wsgi_app = ProxyFix(app.wsgi_app) tasks.run_all_tasks(completed_pool=app.config.get('TASK_COMPLETED_POOL'), completed_sleep=app.config.get('TASK_COMPLETED_SLEEP'), update_metrics_sleep=app.config.get('TASK_UPDATE_METRICS_SLEEP')) return app
def create_app(config='widukind_api.settings.Prod'): env_config = config_from_env('WIDUKIND_API_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) _conf_db(app) app.config['LOGGER_NAME'] = 'widukind_api' app._logger = _conf_logging(debug=app.debug, prog_name='widukind_api') if app.config.get("LOGGING_MONGO_ENABLE", True): _conf_logging_mongo(app) if app.config.get("LOGGING_MAIL_ENABLE", False): _conf_logging_mail(app) _conf_logging_errors(app) _conf_sentry(app) _conf_errors(app) _conf_cache(app) _conf_converters(app) _conf_jsonify(app) _conf_default_views(app) _conf_bp(app) _conf_processors(app) _conf_periods(app) _conf_auth(app) _conf_session(app) _conf_mail(app) app.wsgi_app = ProxyFix(app.wsgi_app) return app
def main(create_app_func=None): """ TODO: commands pour créer fixtures de chaque mode pour démo """ if not create_app_func: from mongo_mail_web.wsgi import create_app create_app_func = create_app class ServerWithGevent(Server): help = description = 'Runs the Flask development server with WSGI SocketIO Server' def __call__(self, app, host, port, use_debugger, use_reloader, threaded, processes, passthrough_errors): #console_path='/console' if use_debugger: app = DebuggedApplication(app, evalex=True) """ TODO: from policyng_web.clients import tasks tasks.start_all(app) """ server = WSGIServer((host, port), app) try: print 'Listening on http://%s:%s' % (host, port) server.serve_forever() except KeyboardInterrupt: pass env_config = config_from_env('MMW_SETTINGS', 'mongo_mail_web.settings.Prod') manager = Manager(create_app_func, with_default_commands=False) manager.add_option('-c', '--config', dest="config", default=env_config) manager.add_command("shell", Shell()) manager.add_command("server", ServerWithGevent(host='0.0.0.0', port=8081)) manager.add_command("config", ShowConfigCommand()) manager.add_command("urls", ShowUrlsCommand()) manager.add_command("reset-db", ResetCommand()) manager.add_command("reset-metrics", ResetMetrics()) manager.add_command('users', ShowUsersCommand()) manager.add_command('create-superadmin', CreateSuperAdminCommand()) manager.run()
def main(create_app_func=None): if not create_app_func: from mongrey.web.wsgi import create_app create_app_func = create_app class ServerWithGevent(Server): help = description = 'Runs the Flask server with Gevent WSGI' def __call__(self, app, host=None, port=None, use_debugger=None, use_reloader=None, threaded=False, processes=1, passthrough_errors=False): config = app.config logger = app.logger if use_debugger: app = DebuggedApplication(app, evalex=True) host = config.get('WEB_HOST', host) port = config.get('WEB_PORT', port) security_by_host = config.get('SECURITY_BY_HOST', False) allow_hosts = config.get('ALLOW_HOSTS', []) server = SecureWSGIServer( (host, port), application=app, security_by_host=security_by_host, allow_hosts=allow_hosts, #log=GeventAccessLogger(logger) ) try: logger.info('Listening on http://%s:%s' % (host, port)) server.serve_forever() except KeyboardInterrupt: pass env_config = config_from_env('MONGREY_SETTINGS', 'mongrey.web.settings.Prod') manager = Manager(create_app_func, with_default_commands=False) manager.add_option('-c', '--config', dest="config", default=env_config) manager.add_command("shell", Shell()) manager.add_command("server", ServerWithGevent()) manager.add_command("config", ShowConfigCommand()) manager.add_command("urls", ShowUrlsCommand()) manager.add_command("default-user", CreateDefaultUserCommand()) manager.add_command("import-whitelist", ImportWhiteList()) manager.run()
def _create_superadmin_user(**kwargs): user = models.User.create_user(username=config_from_env('MMW_SUPERADMIN_EMAIL', '*****@*****.**'), password=config_from_env('MMW_SUPERADMIN_PASSWORD', 'password'), role='superadmin', group=constants.GROUP_DEFAULT)
def main(create_app_func=None): if not create_app_func: from shortener_url.wsgi import create_app create_app_func = create_app class ServerWithGevent(Server): help = description = 'Runs the Flask development server with Gevent WSGI Server' def __call__(self, app, host, port, use_debugger, use_reloader, threaded, processes, passthrough_errors, **kwargs): #print("kwargs : ", kwargs) #{'ssl_key': None, 'ssl_crt': None} if use_debugger: app = DebuggedApplication(app, evalex=True) server = WSGIServer((host, port), app) try: print('Listening on http://%s:%s' % (host, port)) server.serve_forever() except KeyboardInterrupt: pass env_config = config_from_env('SHORTURL_SETTINGS', 'shortener_url.settings.Prod') manager = Manager(create_app_func, with_default_commands=False) #TODO: option de config app pour désactiver run counter manager.add_option('-c', '--config', dest="config", default=env_config) manager.add_command("shell", Shell()) if HAS_GEVENT: manager.add_command("server", ServerWithGevent( host = '0.0.0.0', port=8081) ) manager.add_command("debug-server", Server( host = '0.0.0.0', port=8081) ) else: manager.add_command("server", Server( host = '0.0.0.0', port=8081) ) manager.add_command("config", ShowConfigCommand()) manager.add_command("urls", ShowUrlsCommand()) manager.add_command("assets", ManageAssets()) from flask_security import script manager.add_command('auth-create-user', script.CreateUserCommand()) manager.add_command('auth-create-role', script.CreateRoleCommand()) manager.add_command('auth-add-role', script.AddRoleCommand()) manager.add_command('auth-remove-role', script.RemoveRoleCommand()) manager.add_command('auth-activate-user', script.ActivateUserCommand()) manager.add_command('auth-deactivate-user', script.DeactivateUserCommand()) manager.run()
def create_app(config='widukind_web.settings.Prod'): env_config = config_from_env('WIDUKIND_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) _conf_db(app) app.config['LOGGER_NAME'] = 'widukind_web' app._logger = _conf_logging(debug=app.debug, prog_name='widukind_web') if app.config.get("LOGGING_MONGO_ENABLE", True): _conf_logging_mongo(app) if app.config.get("LOGGING_MAIL_ENABLE", False): _conf_logging_mail(app) _conf_logging_errors(app) extensions.moment.init_app(app) _conf_bootstrap(app) #_conf_themes(app) _conf_sentry(app) #if app.config.get('SESSION_ENGINE_ENABLE', False): # from flask_mongoengine import MongoEngineSessionInterface # app.session_interface = MongoEngineSessionInterface(extensions.db) _conf_errors(app) _conf_cache(app) _conf_converters(app) _conf_jsonify(app) _conf_default_views(app) _conf_bp(app) _conf_record_query(app) _conf_processors(app) _conf_auth(app) _conf_sitemap(app) _conf_session(app) _conf_mail(app) _conf_locker(app) _conf_counters(app) app.wsgi_app = ProxyFix(app.wsgi_app) return app
def create_app(config='mongrey.web.settings.Prod'): env_config = config_from_env('MONGREY_SETTINGS', config) app = Flask(__name__) app.config.from_object(env_config) if not app.config.get('TESTING', False): app.config['LOGGER_NAME'] = 'mongrey' app._logger = utils.configure_logging(debug=app.debug, prog_name='mongrey') utils.SECRET_KEY = app.config.get('SECRET_KEY') _configure_i18n(app) login_manager.init_app(app) settings, storage = utils.get_db_config(**app.config.get('DB_SETTINGS')) if storage == "mongo": _configure_storage_mongo(app) app.config['STORAGE'] = "mongo" if 'DEBUG_TB_PANELS' in app.config: app.config['DEBUG_TB_PANELS'].append( 'flask.ext.mongoengine.panels.MongoDebugPanel') elif storage == "sql": _configure_storage_sql(app) app.config['STORAGE'] = "sql" _configure_session(app) _configure_sentry(app) if app.debug: try: from flask_debugtoolbar import DebugToolbarExtension DebugToolbarExtension(app) except ImportError: pass @app.context_processor def all_processors(): current_lang = session.get(constants.SESSION_LANG_KEY, app.config.get('BABEL_DEFAULT_LOCALE')) return dict( current_theme=app.config.get('DEFAULT_THEME', 'slate'), current_lang=current_lang, langs=app.config.get('ACCEPT_LANGUAGES_CHOICES'), url_for_security=app.login_app.url_for_security, is_hidden=forms._is_hidden, is_required=forms._is_required, ) @app.before_first_request def create_default_user(): _create_default_user(app=app) app.wsgi_app = ProxyFix(app.wsgi_app) return app