Example #1
0
import os
from flask import Flask, redirect, request, render_template, url_for, jsonify, g
from model import *
from forms import *
from werkzeug.utils import secure_filename

# from flask_peewee.rest import RestAPI
import json

# from bson import json_util
from playhouse.shortcuts import *

app = Flask(__name__)
app.secret_key = "asdopiasdijnnrnkjasdkjlkbababooey"
app.config["IMAGES"] = "static/upload/images/"

ALLOWED_IMAGES = set(["png", "jpg", "jpeg"])

# api = RestAPI(app)

# api.register(BeerStyle)

# api.setup()


def allowed_image(filename):
    return "." in filename and filename.rsplit(".", 1)[1] in ALLOWED_IMAGES


@app.route("/api/beer", methods=["GET"])
def _api_beers():
Example #2
0
import libcloud.security

libcloud.security.VERIFY_SSL_CERT = False

from forms import Node

app = Flask(__name__)
app.config["FILTER_NAMES"] = []
app.config.from_pyfile("application.cfg", silent=True)
Driver = get_driver(Provider.RACKSPACE)
conn = Driver(app.config["RACKSPACE_USER"], app.config["RACKSPACE_KEY"])
images = conn.list_images()
images.sort(key=lambda item: item.name)
sizes = conn.list_sizes()
app.config["IMAGES"] = images
app.config["SIZES"] = sizes


def filter_nodes(node):
    return node.name not in app.config["FILTER_NAMES"]


@app.route("/")
def hello():
    nodes = conn.list_nodes()
    nodes = filter(filter_nodes, nodes)
    size_lookup = dict(
        [(size.id, {"cost": size.price * 30 * 24, "name": size.name}) for size in app.config.get("SIZES", [])]
    )
    image_lookup = dict([(image.id, image.name) for image in images])