Example #1
0
#!/usr/bin/env python
# coding=utf8

import os
from flask import Flask, render_template, request
from flask.ext.bootstrap import Bootstrap
import useragent

app = Flask(__name__)
Bootstrap(app)

app.config["BOOTSTRAP_USE_MINIFIED"] = True
app.config["BOOTSTRAP_USE_CDN"] = False
app.config["BOOTSTRAP_FONTAWESOME"] = True
app.config["BOOTSTRAP_GOOGLE_ANALYTICS_ACCOUNT"] = "UA-36835748-1"


@app.route("/")
def index():
    ua = useragent.detect(str(request.user_agent))
    os = detectOS(ua)
    return render_template("index.html")


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


def detectOS(ua):
    os_string = ua.os.family.lower()
Example #2
0
import re

from flask import Flask, render_template, redirect, abort

from flask.ext.bootstrap import Bootstrap
from flask.ext.wtf import Form, TextField, ValidationError

app = Flask(__name__)

app.config["BOOTSTRAP_USE_MINIFIED"] = True
app.config["BOOTSTRAP_USE_CDN"] = True
app.config["BOOTSTRAP_FONTAWESOME"] = True
app.config["SECRET_KEY"] = "devkey"

app.config.from_object(__name__)
app.config.from_envvar("FLASKAPP_SETTINGS", silent=True)

Bootstrap(app)


def valid_url(string):
    return re.match("http(s){0,1}://www.evernote.com/shard/.+", string, re.I) is not None


class URLForm(Form):
    url = TextField("Evernote share URL", description="Please enter Evernote share URL.")

    def validate_url(form, field):
        if not valid_url(field.data):
            raise ValidationError("This does not appear to be " / "a valid Evernote Share URL")