def main(test=False): """Start tornado running hactar.""" conf = load(open('config.json', 'rb'))['production'] if test: config_app(app) else: secrets = load(open(conf['SECRETS'], 'rb')) conf['USERNAME'] = secrets['hactar']['username'] conf['PASSWORD'] = secrets['hactar']['password'] conf['SECRET_KEY'] = secrets['installed']['client_secret'] app.config.update(conf) setup('production') logpath = os.path.join(conf['LOG_DIR'], conf['LOG_MAIN']) handler = logging.handlers.RotatingFileHandler(logpath, maxBytes=100000, backupCount=4) fmtr = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') handler.setFormatter(fmtr) logger = logging.getLogger() logger.setLevel(logging.INFO) logger.addHandler(handler) with app.app_context(): db.init_app(app) if not os.path.exists(conf['SQLALCHEMY_DATABASE_URI'].lstrip('sqlite:///')): with app.test_request_context(): db.create_all() app.celery_running = True app.logger.debug('starting app with config: %s' % app.config) http_server = HTTPServer(WSGIContainer(app)) http_server.listen(8080) IOLoop.instance().start()
def main(test=False): """Start tornado running hactar.""" conf = load(open('config.json', 'rb'))['production'] if test: config_app(app) else: secrets = load(open(conf['SECRETS'], 'rb')) conf['USERNAME'] = secrets['hactar']['username'] conf['PASSWORD'] = secrets['hactar']['password'] conf['SECRET_KEY'] = secrets['installed']['client_secret'] app.config.update(conf) setup('production') logpath = os.path.join(conf['LOG_DIR'], conf['LOG_MAIN']) handler = logging.handlers.RotatingFileHandler(logpath, maxBytes=100000, backupCount=4) fmtr = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') handler.setFormatter(fmtr) logger = logging.getLogger() logger.setLevel(logging.INFO) logger.addHandler(handler) with app.app_context(): db.init_app(app) if not os.path.exists( conf['SQLALCHEMY_DATABASE_URI'].lstrip('sqlite:///')): with app.test_request_context(): db.create_all() app.celery_running = True app.logger.debug('starting app with config: %s' % app.config) http_server = HTTPServer(WSGIContainer(app)) http_server.listen(8080) IOLoop.instance().start()
def main(): """ Runtime management of the picoCTF WebFrontend """ parser = ArgumentParser(description="picoCTF API configuration") parser.add_argument("-v", "--verbose", action="count", help="increase verbosity", default=0) parser.add_argument("-p", "--port", action="store", help="port the server should listen on.", type=int, default=8001) parser.add_argument("-l", "--listen", action="store", help="host the server should listen on.", default="0.0.0.0") parser.add_argument("-d", "--debug", action="store_true", help="run the server in debug mode.", default=False) args = parser.parse_args() keyword_args, _ = object_from_args(args) app.config_app() \ .run(host=args.listen, port=args.port, debug=args.debug)
def __init__(self): from app import config_app from instance.config import config import os with config_app(config.get(os.environ.get("FLASK_ENV"), 'default')) as app: url_db = app.config["SQLALCHEMY_DATABASE_URI"] self.__engine = create_engine( url_db, pool_size=5, # default in SQLAlchemy max_overflow=10, # default in SQLAlchemy pool_timeout=1, # raise an error faster than default ) self.__thread_safe_session_factory = scoped_session( sessionmaker(bind=self.__engine)) self.__default_message = "Auto-generated note, the average rating of the game at boardgamegeek.com" self.__genres_dict = {}
def client(): from app import app, config_app from views import index, upload_save # noqa config_app(flask_config=FlaskTestConfig) return app.test_client()
from libs.http import createFlaskApp from app import config_app import sys from PyQt5.QtWidgets import QApplication from gui import Gui if __name__ == "__main__": gui = Gui() QApp = QApplication(sys.argv) gui.init() # httpApp = create_http_app(gui) httpApp = createFlaskApp({ "host": "0.0.0.0", "debug": False, "port": 3100 }, template_folder="data/view", static_folder="data/statics") httpApp.attr = ("gui", gui) config_app(httpApp) sys.exit(QApp.exec_())
from app import app, config_app from views import index, upload_save # noqa if __name__ == '__main__': import config config_app(flask_config=config.FlaskConfig, mongo_db_config=config.MongoDbConfig, misc_config=config.MiscConfig) app.run()
def fresh_client(): config_app(flask_config=FlaskTestConfig, misc_config=MiscConfig) return app.test_client()
def test_app_modules_config(): assert config_app() == True
import logging from app import config_app app = config_app() if __name__ != '__main__': logging.basicConfig( format= '%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s', datefmt='%Y-%m-%d:%H:%M:%S', level=logging.DEBUG) gunicorn_logger = logging.getLogger('gunicorn.error') app.logger.handlers = gunicorn_logger.handlers app.logger.setLevel(gunicorn_logger.level) if __name__ == '__main__': logging.basicConfig( format= '%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s', datefmt='%Y-%m-%d:%H:%M:%S', level=logging.DEBUG) logger = logging.getLogger(__name__) app.run(host='0.0.0.0')