def create_app(config='CTFd.config'): app = Flask(__name__) with app.app_context(): app.config.from_object(config) app.jinja_loader = ThemeLoader(os.path.join(app.root_path, app.template_folder), followlinks=True) from CTFd.models import db, Teams, Solves, Challenges, WrongKeys, Keys, Tags, Files, Tracking url = make_url(app.config['SQLALCHEMY_DATABASE_URI']) if url.drivername == 'postgres': url.drivername = 'postgresql' db.init_app(app) try: if not (url.drivername.startswith('sqlite') or database_exists(url)): create_database(url) db.create_all() except OperationalError: db.create_all() except ProgrammingError: ## Database already exists pass else: db.create_all() app.db = db cache.init_app(app) app.cache = cache if not get_config('ctf_theme'): set_config('ctf_theme', 'original') #Session(app) from CTFd.views import views from CTFd.challenges import challenges from CTFd.scoreboard import scoreboard from CTFd.auth import auth from CTFd.admin import admin from CTFd.utils import init_utils, init_errors, init_logs init_utils(app) init_errors(app) init_logs(app) app.register_blueprint(views) app.register_blueprint(challenges) app.register_blueprint(scoreboard) app.register_blueprint(auth) app.register_blueprint(admin) from CTFd.plugins import init_plugins init_plugins(app) return app
from flask import Flask from flask import request import config from tender.tender_manager import TenderManager from user.user_manager import UserManager from utils import db from province_city.province_city_manage import ProvinceCityManage from utils import cache app = Flask(__name__) app.config.from_object(config) db.init_app(app=app) cache.init_app(app=app) @app.route('/') def hello_world(): return 'Hello World!' # 增加用户 @app.route('/add_user/', methods=['GET', 'POST']) def add_user(): # return 'success' userManager = UserManager() data = {} data['status'] = 'failed' data[