def create_app(config_class=site_config.Config): # Create app app = flask.Flask(__name__) app.config.from_object(config_class) app.wsgi_app = werkzeug.contrib.fixers.ProxyFix(app.wsgi_app) # Set up extensions bcrypt.init_app(app) csrf.init_app(app) db.init_app(app) login_manager.init_app(app) mail.init_app(app) migrate.init_app(app, db) moment.init_app(app) flask_shelve.init_app(app) # Import models for db migration and setup import_models() # Set up jinja utilities register_jinja_utils(app) # Enable redis queue app.redis = redis.Redis.from_url(app.config["REDIS_URL"]) app.task_queue = rq.Queue(app.config["RQ_NAME"], connection=app.redis) # Set up logging if we aren't in debug/testing mode set_up_logger(app) # Register tasks from personal_site import tasks app.registered_tasks = tasks.REGISTERED_TASKS # Register error handlers if we aren't in debug/testing mode register_error_handlers(app) # Import all blueprints from controllers from personal_site.base.controllers import default from personal_site.admin.controllers import admin from personal_site.auth.controllers import auth from personal_site.forum.controllers import forum from personal_site.learn.controllers import learn from personal_site.profile.controllers import profile # Register blueprints app.register_blueprint(default) app.register_blueprint(admin) app.register_blueprint(auth) app.register_blueprint(forum) app.register_blueprint(learn) app.register_blueprint(profile) return app
import logging.config logging.config.fileConfig( fname='logging.ini' #, disable_existing_loggers=False ) L = logging.getLogger( __name__ ) import os from flask import Flask, url_for, jsonify, make_response # extensions import flask_shelve as shelve from geode.flask.views import geodeBlueprint from geode.flask.binding import GeodeForFlask L.info("Creating new app instance") app = Flask( __name__ , static_folder="static" # XXX, we do not have static really... #, template_folder='geomlib/' ) app.config['SHELVE_FILENAME'] = 'shelve.db' shelve.init_app(app) app.register_blueprint( geodeBlueprint ) gdmlLib = GeodeForFlask(app) print(app.url_map)
import os import os.path from flask import Flask, render_template, g from flask_cas import CAS, login_required from flask_shelve import get_shelve, init_app from emailhint import send_hint from linkedlist import LINKED_LIST, LL_END app = Flask(__name__) app.config['CAS_SERVER'] = 'https://login.case.edu' app.config['CAS_AFTER_LOGIN'] = '******' app.config['SHELVE_FILENAME'] = 'scores' cas = CAS(app, '/cas') init_app(app) EMAIL_ENABLED = False # Add flags here mapping to their number in our list. For sure a better way # to go about this, but this is quick and dirty. Also should we standardize # flag format lol? flag_map = { 'flag{I_lied_this_is_a_flag}': 1, 'flag{spoofer_no_spoofing}': 2, 'flag{All men are created equal}': 3, 'flag{touch_and_go}': 4, 'flag{never_break_the_chain}': 6, 'flag{gary-ignatius-teabody}': 12, 'flag{mailto:[email protected]}': 13, 'flag{:poopemoji:}': 14, 'FLAG{c_is_the_best_and_you_should_all_learn_it}': 15,
ext = Sitemap(app=app) #app.config['SESSION_TYPE'] = 'filesystem' #app.config['SHELVE_FILENAME'] = 'shelve.db' #app.config['SHELVE_LOCKFILE'] = 'shelve.db.lock' #app.config['SESSION_TYPE'] = 'null' #app.config['SESSION_PERMANENT'] = 'False' Bootstrap(app) #app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER #app.config['MAX_CONTENT_LENGTH'] = 32 * 4096 #12/19/2018 app.extensions['bootstrap']['cdns']['slate'] = WebCDN( "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/slate/") app.extensions['bootstrap']['cdns']['cyborg'] = WebCDN( "https://stackpath.bootstrapcdn.com/bootswatch/3.3.7/cyborg/") nav.init_app(app) flask_shelve.init_app(app) _samples = [] # Views and other stuff def allowed_file(filename): """ Make sure filetype has allowed extension. * docx: most reliable * odt: through textract (spaces between words disappear, as do apostrophes) * txt: works fine """
return g.menu BOT = RestaurantBot(get_menu) BOT.add_menu_action("r1", ["r1", "today"]) BOT.add_menu_action("r2", ["r2", "today"]) BOT.add_menu_action("r3", ["r3", "today"]) BOT.add_menu_action("today", ["today"]) BOT.add_menu_action("tomorrow", ["tomorrow"]) BOT.add_menu_action("vegetarian", ["vegetarian", "today"]) APP = Flask(__name__) APP.debug = True APP.config["SHELVE_FILENAME"] = "shelve.db" shelve.init_app(APP) @APP.route("/telegram/{}/".format(TELEGRAM_BOT_TOKEN), methods=["POST"]) def handle_telegram(): resp = BOT.respond(request.json) if resp is None: return "OK" return jsonify(resp) @APP.route("/<path:path>") @cross_origin() def json_menu(path): """ Read the query string, get the menu and