def init_app_config(app, config): class CFG(object): pass cfg = CFG() for name in config.options('app'): setattr(cfg, name.upper(), config.get('app', name)) cfg.PORT = config.getint('app', 'PORT') cfg.HOST = config.get('app', 'HOST') cfg.MAX_CONTENT_LENGTH = config.getint('app', 'MAX_CONTENT_LENGTH') cfg.DEBUG = config.getboolean('app', 'DEBUG') server_name = os.getenv('ORANGEAPP_SERVER_URL', '') if server_name: cfg.SERVER_NAME = server_name config.set('app', 'SERVER_NAME', server_name) app.config.from_object(cfg)
def init_app_config(app, config): class CFG(object): pass cfg = CFG() for name in config.options('app'): setattr(cfg, name.upper(), config.get('app', name)) cfg.PORT = config.getint('app', 'PORT') cfg.HOST = config.get('app', 'HOST') cfg.MAX_CONTENT_LENGTH = config.getint('app', 'MAX_CONTENT_LENGTH') cfg.DEBUG = config.getboolean('app', 'DEBUG') server_name = os.getenv('ORANGEAPP_SERVER_URL', '') if server_name: cfg.SERVER_NAME = server_name config.set('app', 'SERVER_NAME', server_name) app.config.from_object(cfg)
def main(): opt, args, parser = parseOptions() profile = debug = False if opt.profile is True: profile = True if opt.debug is True: debug = True if opt.host: config.set("app", "HOST", opt.host) if opt.port: config.set("app", "PORT", opt.port) if opt.no_server_name: config.remove_option("app", "SERVER_NAME") app = create_app(config) if profile: app.config["PROFILE"] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) app.logger.info("Running app in Profile state...") app.run(host=app.config["HOST"], port=app.config["PORT"], debug=debug or app.debug)
def main(): opt, args, parser = parseOptions() profile = debug = False if opt.profile is True: profile = True if opt.debug is True: debug = True if opt.host: config.set('app', 'HOST', opt.host) if opt.port: config.set('app', 'PORT', opt.port) if opt.no_server_name: config.remove_option('app', 'SERVER_NAME') app = create_app(config) if profile: app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) app.logger.info('Running app in Profile state...') app.run(host=app.config['HOST'], port=app.config['PORT'], debug=debug or app.debug)