Example #1
0
def base_app():
    global app
    app = Flask("backend")
    app.config.overrides = {}

    logging.info("Connecting to database...")
    engine = create_engine(backend.settings.db_connection)
    app.engine = engine
    base = automap_base()
    base.prepare(engine, reflect=True)

    session = Session(engine)
    app.base = base
    app.session = session
    app.Decl_Base = declarative_base()

    from backend.models import Members

    app.Decl_Base.metadata.create_all(app.engine)

    # Create the Flask-Restless API manager.
    app.api_manager = flask.ext.restless.APIManager(app, session=app.session)
    app.api_manager.create_api(Members, methods=["GET", "POST", "PATCH", "DELETE"], collection_name="members")

    return app

    @app.route("/shutdown", methods=["POST"])  # pragma: no cover
    def shutdown():  # pragma: no cover
        logging.info("shutting down server")
        shutdown_server()
        return "server shutting down"
Example #2
0
File: app.py Project: tUn4/boofuzz
from flask import Flask, render_template, redirect
import re

app = Flask(__name__)
app.session = None


def commify(number):
    number = str(number)
    processing = 1
    regex = re.compile(r"^(-?\d+)(\d{3})")
    while processing:
        (number, processing) = regex.subn(r"\1,\2", number)
    return number


@app.route("/togglepause")
def pause():
    # Flip our state
    app.session.is_paused = not app.session.is_paused
    return redirect("/")


@app.route("/view_crash/<int:crash_id>")
def view_crash(crash_id):
    return render_template("view_crash.html", crashinfo=app.session.procmon_results[crash_id])


@app.route("/")
def index():
    crashes = []