Example #1
0
app.config["FRIENDLY_NAME"] = friendly_name
app.config["SUPPORT_EMAIL"] = support_email
app.config["REMINDERS_EXPIRE"] = reminders_expire


# Google OAuth2 setup
secrets = None
with open("client_secrets.json") as f:
    secrets = json.load(f)["web"]

app.config["OAUTH2CALLBACK_PATH"] = "/oauth2callback"
app.config["GOOGLE_CLIENT_ID"] = secrets["client_id"]
app.config["GOOGLE_CLIENT_SECRET"] = secrets["client_secret"]
app.config["GOOGLE_LOGIN_REDIRECT_URI"] = "%s://%s%s" % (
    app.config["PREFERRED_URL_SCHEME"],
    app.config["SERVER_NAME"],
    app.config["OAUTH2CALLBACK_PATH"],
)
app.config["GOOGLE_LOGIN_DOMAIN"] = gafe_domain
app.config["GOOGLE_LOGIN_SCOPE"] = " ".join(
    [
        "email",
        "profile",
        "https://www.googleapis.com/auth/plus.login",
        "https://www.googleapis.com/auth/calendar",
        "https://www.googleapis.com/auth/gmail.modify",
    ]
)
app.config["GOOGLE_SERVICE_ACCOUNT_SCOPE"] = " ".join(
    ["email", "profile", "https://www.googleapis.com/auth/calendar", "https://www.googleapis.com/auth/gmail.modify"]
)
Example #2
0
env = Environment(loader=PackageLoader("project", "templates"))
env.filters["urlencode"] = urlencode

engine = create_engine("sqlite:///itemcatalog.db")
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

# limit the size of the content to ~ 5 MB (for the picture upload)
app.config["MAX_CONTENT_LENGTH"] = 5 * 1024 * 1024

app.config["GOOGLE_LOGIN_CLIENT_ID"] = "345630431964-cgq7hq1od0bp2jgf8v4525e4tqrrcbk0.apps.googleusercontent.com"
app.config["GOOGLE_LOGIN_CLIENT_SECRET"] = "YYbX24T9UvJI-jlJruFpwvno"
app.config["GOOGLE_LOGIN_REDIRECT_URI"] = "http://localhost:8000/oauth2callback/"

login_manager = LoginManager()
login_manager.init_app(app)
googlelogin = GoogleLogin(app, login_manager)


@app.route("/")
def latestItems():
    """Lists the items which were recently created in descending order (newest item first)."""
    categories = session.query(Category).all()
    items = session.query(Item).order_by(desc(Item.creation_date)).limit(10).all()
    return render_template("latest_items.html", categories=categories, items=items)


@app.route("/category/<int:category_id>/items/")