Example #1
0
def start_app():
    app = Flask(__name__)
    app.config["S3_BUCKET_NAME"] = "readsy"
    app.config["S3_CDN_DOMAIN"] = "dwdhruapbuq08.cloudfront.net"
    app.config["S3_USE_HTTPS"] = False
    app.config["USE_S3_DEBUG"] = True  # should be true
    app.config["AWS_ACCESS_KEY_ID"] = os.environ["AWS_ACCESS_KEY_ID"]
    app.config["AWS_SECRET_ACCESS_KEY"] = os.environ["AWS_SECRET_ACCESS_KEY"]

    s3 = FlaskS3()
    s3.init_app(app)

    assets = Environment()
    # use closure_js once i have java 7
    js = Bundle(
        "js/jquery.cookie.js",
        "js/mousetrap.min.js",
        "js/app.js",
        "js/froala_editor.min.js",
        filters="rjsmin",
        output="gen/packed.js",
    )
    css = Bundle(
        "css/bootstrap.min.css",
        "css/froala_editor.min.css",
        "css/bootstrapcustom.css",
        filters="cssmin",
        output="gen/packed.css",
    )
    assets.register("js_all", js)
    assets.register("css_all", css)
    app.config["ASSETS_DEBUG"] = False
    assets.init_app(app)
    app.config["FLASK_ASSETS_USE_S3"] = True  # should be true

    return app
Example #2
0
from flask_s3 import FlaskS3
from waitress import serve

# Hard to PORT.
PORT = int(os.environ.get("PORT", 5000))

# Hard-coded source of IDOLS.
IDOL_SOURCE = "http://aidoru-bomb.herokuapp.com/random"

# Let's create a Flask.
app = Flask(__name__)
app.debug = getattr(os.environ, "DEBUG", False)

# FlaskS3 Configuration
app.config["S3_BUCKET_NAME"] = "maximumidol"
app.config["S3_USE_HTTPS"] = "false"
s3 = FlaskS3(app)


@app.route("/")
@app.route("/random")
def home():
    r = requests.get(IDOL_SOURCE).json()
    gif = r.get("idol", "")
    return render_template("home.html", gif=gif)


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