Example #1
0
def create_backend_app(service):
    from werkzeug.routing import Map

    # Create the backend_app
    backend_app = Flask(__name__)
    backend_app.debug = True
    backend_app.service = service

    # Reset view functions to reset the app
    backend_app.view_functions = {}
    backend_app.url_map = Map()
    backend_app.url_map.converters["regex"] = RegexConverter
    backend = BACKENDS[service]
    for url_path, handler in backend.flask_paths.items():
        if handler.__name__ == "dispatch":
            endpoint = "{0}.dispatch".format(handler.__self__.__name__)
        else:
            endpoint = None

        if endpoint in backend_app.view_functions:
            # HACK: Sometimes we map the same view to multiple url_paths. Flask
            # requries us to have different names.
            endpoint += "2"

        backend_app.add_url_rule(
            url_path,
            endpoint=endpoint,
            methods=HTTP_METHODS,
            view_func=convert_flask_to_httpretty_response(handler),
            strict_slashes=False,
        )

    backend_app.test_client_class = AWSTestHelper
    return backend_app
Example #2
0
import psycopg2
from flask import Flask, render_template, redirect, flash, session
import requests
from flask.ext.wtf import Form
from wtforms import StringField, PasswordField
import riotwatcher
import atexit


app = Flask(__name__)
app.secret_key = "A0Zr98j/3yX R~XHH!jmN]LWX/,?RT"
app.service = "http://127.0.0.1:5001/api/"
key = "1dbf97cc-5028-4196-a05c-6645adc80bef"
w = riotwatcher.RiotWatcher(key)


@app.route("/")
def index():
    return render_template("index.html")


@app.route("/sign-out")
def sign_out():
    if "username" in session:
        del session["username"]
    return redirect("/")


@app.route("/sign-up", methods=["GET", "POST"])
def sign_up():
    class SignUpForm(Form):