def create_app(debug=False):
    """Create an application."""
    app = Flask(__name__)
    app.debug = debug
    app.config['SECRET_KEY'] = 'sufjdhlauknyrioe3q8740918ur-013umu4liyusa'
    app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(1)
    app.secret_key = 'deep is secret zomg'

    from .main import main as main_blueprint
    return app
Beispiel #2
from flask_oauth import OAuth
from urllib2 import urlopen
from jinja2 import Template
import datetime
from json import dumps
import uuid

# Note: To deal with potential username spoofing, check the username
# in the session with every action that actually does something
# ie creating a sound bite, deleting, etc

# Create app
app = Flask(__name__)
# FIXME: Disable debug mode in prodoction!
app.config['DEBUG'] = False
app.config['SECRET_KEY'] = 'replace_me_eventually'

# MongoDB config
# TODO load from file
app.config['MONGODB_SETTINGS'] = {
                                    'DB': 'mangoes', 
                                    'USERNAME' : 'breakpoint', 
                                    'PASSWORD' : 'googlejump', 
                                    'HOST' : '', 
                                    'PORT': 10035 

# Create database connection object
db = MongoEngine(app)
Beispiel #3
from flask import Flask, render_template
from flask.ext.bootstrap import Bootstrap
from flask.ext.moment import Moment
from import Form
from wtforms import StringField, SubmitField
from wtforms.validators import Required
#from datetime import datetime

class NameForm(Form):
    name = StringField('What is your name?', validators=[Required()])
    submit = SubmitField('Submit')

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'  
###unsafe. should be in a config file ultimately.
bootstrap = Bootstrap(app)
#moment = Moment(app)

@app.route('/', methods=['GET','POST'])
def index():
    form = NameForm()
    if form.validate_on_submit():
        session['name'] =
        return redirect(url_for('index'))
    return render_template('index.html', form=form, name=session.get('name))

def user(name):
    return render_template('user.html', name=name)
Beispiel #4
from datetime import datetime
from flask import Flask, render_template, url_for, request, redirect, flash, jsonify
from forms import SongForm

#from logging import DEBUG

app = Flask(__name__)
app.config['SECRET_KEY'] = '\xddg\xf8\xab\xe9\x94\x97\x05rD\x0f\xb8\xaa\x17\xd4\x82\x1cY\xc8wHl6\x1e'

class User:
	def __init__(self, firstname, lastname):
		self.firstname = firstname
		self.lastname = lastname

	def initials(self):
		return "{}. {}.".format(self.firstname[0], self.lastname[0])

def index():
#	return render_template('index.html', title="Title passed from view to template", 
#								text="Text passed from view to template ")
	return render_template('index.html')

songlist = ["Mexican Cousin", "The Curtain With", "Sample in a Jar", "Yarmouth Road", "The Landlady", "Army of One", "Kill Devil Falls", "Bathtub Gin", "Funky Bitch", "The Moma Dance", "Saw It Again", "Down with Disease", "Roggae", "Crosseyed and Painless", "Farmhouse", "Mike's Song", "Bug", "Weekapaug Groove"]

from flask import Flask, render_template
from flask.ext.sqlalchemy import SQLAlchemy
from import current_user, login_required, RoleMixin, Security, \
    SQLAlchemyUserDatastore, UserMixin, utils
from flask_mail import Mail
from flask.ext.admin import Admin
from flask.ext.admin.contrib import sqla

from wtforms.fields import PasswordField

# Initialize Flask and set some config values
app = Flask(__name__)
# Replace this with your own secret key
app.config['SECRET_KEY'] = 'super-secret'
# The database must exist (although it's fine if it's empty) before you attempt to access any page of the app
# in your browser.
# I used a PostgreSQL database, but you could use another type of database, including an in-memory SQLite database.
# You'll need to connect as a user with sufficient privileges to create tables and read and write to them.
# Replace this with your own database connection string.
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres:xxxxxxxx@localhost/flask_example'

# Set config values for Flask-Security.
# We're using PBKDF2 with salt.
app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512'
# Replace this with your own salt.
app.config['SECURITY_PASSWORD_SALT'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

# Flask-Security optionally sends email notification to users upon registration, password reset, etc.
Beispiel #6
Flask Documentation:
Jinja2 Documentation:
Werkzeug Documentation:

This file creates your application.

import os
from flask import Flask, render_template, request, redirect, url_for

app = Flask(__name__)

app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'this_should_be_configured')

# Routing for your application.

def home():
    """Render website's home page."""
    return render_template('home.html')

def about():
    """Render the website's about page."""
    return render_template('about.html')
from flask.ext.stormpath import (

app = Flask(__name__)
app.config['SECRET_KEY'] = 'nananananananana'
app.config['STORMPATH_API_KEY_FILE'] = ''
app.config['STORMPATH_APPLICATION'] = 'batman_splash'
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0

stormpath_manager = StormpathManager(app)

def show_index():
	import netifaces
	interfaces = [interface for interface in netifaces.interfaces() if interface.find('wlan') != -1]
	return render_template('index.html', option_list=interfaces)

def show_error():
	return render_template('error.html')
Beispiel #8
FLATPAGES_ROOT = '/app/content'
POST_DIR = 'posts'
# PAGE_DIR = 'pages'
# PER_PAGE = 3

app = Flask(__name__)
flatpages = FlatPages(app)
freezer = Freezer(app)
moment = Moment(app)
app.config['SECRET_KEY'] = 'Hard to guess String'

def get_brow_info():
    user_agent = request.headers.get('User-Agent')
    referer = request.headers.get('Referer')
    ip,user = request.remote_addr,request.remote_user
    getinfo['user_agent'] = user_agent
    getinfo['referer'] = referer
    getinfo['ip'] = ip
    getinfo['user'] = user
    return  getinfo

def url():
Beispiel #9
Small-Example: email is shown as a link to the edit view of the record.
from flask import Flask, Markup, url_for
from flask_sqlalchemy import SQLAlchemy
import flask_admin as admin
from flask_admin.contrib import sqla

app = Flask(__name__)  # Create application
app.config['SECRET_KEY'] = '123456790'  # Create dummy secrey key so we can use sessions
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite' # Create database
db = SQLAlchemy(app)

@app.route('/')  # Flask views
def index():
    return '<a href="/admin/">Click me to get to Admin!</a>'
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(255))
    last_name = db.Column(db.String(255))
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    def __str__(self):
class uAdmin(sqla.ModelView):

    def _user_formatter(view, context, model, name):
        return Markup(
Beispiel #10
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#This file is about the View module

from flask import Flask, render_template, session, redirect, url_for, request, flash
from flask.ext.login import login_user
from .import auth
from .form import LogInForm
from ..model import Admin
from ..model import Base

app = Flask(__name__)
app.config['SECRET_KEY'] = 'ROOT'

def index():
	sql = 'select username from admin'
	names = []
	for name in cur.fetchall():
	return render_template('index.html', name_list = names)

@app.route('/login', methods=['GET', 'POST'])
def login():
	form = LogInForm()
Beispiel #11

>>>>>>> origin/master
app = Flask(__name__, static_folder='static', static_url_path='')

#Start Server at Port 5000
if os.getenv("VCAP_APP_PORT"):
    port = int(os.getenv("VCAP_APP_PORT"))
    port = 80

# use for encrypt session
app.config['SECRET_KEY'] = 'b56936b292f44fc397f77d882b3418ee'

login_manager = LoginManager()

class UserNotFoundError(Exception):
class User(UserMixin):
    '''Simple User class'''
    USERS = {
        # user : 
        'Jessie Pullaro': '2345'
Beispiel #12
from flask import Flask
from flask import render_template

from forms import SearchForm

app = Flask(__name__)
app.config['DEBUG'] = True
app.config['SECRET_KEY'] = 'super_secret_key'

def home():
    return "Home"

@app.route("/search/", methods=['GET', 'POST'])
def search():
    form = SearchForm()
    return render_template('search.html', form=form)

def add():
    return "Add"

if __name__ == "__main__":
Beispiel #13
from wtforms import StringField, SubmitField, PasswordField, BooleanField
from wtforms import RadioField, IntegerField, TextAreaField, SelectField
from wtforms.fields.html5 import DateField, DateTimeField
from wtforms.validators import Required, IPAddress
from wtforms.validators import ValidationError, Optional
import json
import re
from flask import jsonify
from acitoolkit.acitoolkit import Credentials
import difflib

# Create application
app = Flask(__name__, static_folder='static')

# Cross site replay security
app.config['SECRET_KEY'] = 'Dnit7qz7mfcP0YuelDrF8vLFvk0snhwP'
app.config['CSRF_ENABLED'] = True
csrf = CsrfProtect(app)

bootstrap = Bootstrap(app)

# Create in-memory database
app.config['DATABASE_FILE'] = 'snapshots.sqlite'
app.config['SQLALCHEMY_DATABASE_URI'] = ('sqlite:///' +
app.config['SQLALCHEMY_ECHO'] = True
db = SQLAlchemy(app)

# Create the ACI Config Database
cdb = ConfigDB()
versions = cdb.get_versions()
from flask import Flask, flash,render_template, url_for, request, redirect
from werkzeug import secure_filename
import os
import numpy as np

from SudokuImage import SudokuImage
from Sudoku import Sudoku

application = Flask(__name__)

application.config['UPLOAD_FOLDER'] = 'static/uploads/'
application.config['ALLOWED_EXTENSIONS'] = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
application.config['SECRET_KEY'] = "hard to guess!string"

@application.route('/', methods=['GET', 'POST'])
@application.route('/index', methods=['GET', 'POST'])
def index():

    if request.method == 'POST':
        # Get the name of the uploaded file
        file = request.files['file']
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
  ['UPLOAD_FOLDER'], filename))

            return redirect(url_for('sudoku',
                                    fname = filename))
Beispiel #15
# -*- coding: utf-8 -*-
"""Postfix Rate Control is an API REST coding in python
   :synopsis: This API can update the MX configuration of postfix server connected to PCR.
   ..moduleauthor:: Damien Mathieu <>
from system import return_listserver, return_domains, return_domain_values, return_domain_deleted, return_domain_added, return_domain_updated, return_get_transport, return_add_transport, return_del_transport, return_del_queue

from flask import Flask, abort, request, jsonify, g, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.httpauth import HTTPBasicAuth
from passlib.apps import custom_app_context as pwd_context
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer, BadSignature, SignatureExpired

app = Flask(__name__)

app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'

# extensions
db = SQLAlchemy(app)
auth = HTTPBasicAuth()

class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key = True)
    username = db.Column(db.String(32), index = True)
    password_hash = db.Column(db.String(64))

    def hash_password(self, password):
        self.password_hash = pwd_context.encrypt(password)
Beispiel #16
__author__ = 'miholeus'

from flask import Flask
from flask.ext.mongoengine import MongoEngine

def register_blueprints(app):
    # Prevents circular imports
    from src.views import bp

app = Flask(__name__)
app.config['MONGODB_SETTINGS'] = {"DB" : "python"}
app.config['SECRET_KEY'] = 'MY_S3CR3T_KEY'

db = MongoEngine(app)


if __name__ == '__main__':
Beispiel #17
from flask import Flask
#import spdb ; spdb.start(0)

import peewee

import flask_admin as admin
from flask_admin.contrib.peewee import ModelView

app = Flask(__name__)
app.config['SECRET_KEY'] = '123456790'

db = peewee.SqliteDatabase('test.sqlite', check_same_thread=False)

class BaseModel(peewee.Model):
    class Meta:
        database = db

class User(BaseModel):
    username = peewee.CharField(max_length=80)
    email = peewee.CharField(max_length=120)

    def __unicode__(self):
        return self.username

class People(BaseModel):
    first_name   = peewee.CharField(max_length=64)
    middle_name  = peewee.CharField(max_length=64)
    last_name    = peewee.CharField(max_length=64)

    pspt_number  = peewee.IntegerField()
    pspt_address = peewee.CharField(max_length=120)
Beispiel #18
# -*- coding:utf-8 -*-

from flask import Flask, render_template, redirect, request, url_for
from flask_bootstrap import Bootstrap
from flask_wtf import Form
from wtforms import StringField, SubmitField, PasswordField
from wtforms.validators import Required

class NameForm(Form):
    Name = StringField('What is your name?', validators=[Required()])
    Password = PasswordField('Please input password', validators=[Required()])
    submit = SubmitField('Submit')

app = Flask(__name__)
app.config['SECRET_KEY'] = 'xiaosong'
bootstrap = Bootstrap(app)

def page_not_found(e):
    return render_template('404.html'),404

def internal_server_error(e):
    return render_template('500.html'),500

@app.route('/', methods=['GET', 'POST'])
def index():
    name = None
    form = NameForm()
    if form.validate_on_submit():
Beispiel #19
from yoi import middleware
from yoi.resources import static_url

app = Flask(__name__)
app.request_class = dweeb.Request

app.genshi = Genshi(app)
app.db = SQLAlchemy(app)


# FIXME - Use app.config.from_object
app.config['DEBUG'] = True
app.config['PROPAGATE_EXCEPTIONS'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = database_url
app.config['SECRET_KEY'] = secret

if canonical_domain:
    app.config['SESSION_COOKIE_DOMAIN'] = canonical_domain
app.config['SESSION_COOKIE_HTTPONLY'] = True
app.config['SESSION_COOKIE_SECURE'] = always_secure

# Global HTTP response headers
cache_headers = [
    ('Cache-Control', 'public'),
no_cache_headers = [
    ('Cache-Control', 'no-cache'),
    ('Expires', 'Sat, 07 Jul 1979 23:00:00 GMT'),
hsts_headers = [
Beispiel #20
from flask import Flask, render_template, redirect, session
import hashlib
from flask_debugtoolbar import DebugToolbarExtension
from models import backend, User, Post, Comment, Vote
from conf import SECRET_KEY

app = Flask(__name__)
app.debug = True
app.config['SECRET_KEY'] = SECRET_KEY
toolbar = DebugToolbarExtension(app)

if __name__ == '__main__':, port=8899)
import sys
import uuid
from functools import wraps

from flask import Flask, g, request, send_from_directory, abort, request_started
from flask_cors import CORS
from flask_restful import Resource, reqparse
from flask_restful_swagger_2 import Api, swagger, Schema

from neo4j.v1 import GraphDatabase, basic_auth, ResultError

from . import config

app = Flask(__name__)
app.config['SECRET_KEY'] = 'super secret guy'
api = Api(app, title='Neo4j Movie Demo API', api_version='0.0.10')

driver = GraphDatabase.driver('bolt://localhost', auth=basic_auth(config.DATABASE_USERNAME, str(config.DATABASE_PASSWORD)))

def get_db():
    if not hasattr(g, 'neo4j_db'):
        g.neo4j_db = driver.session()
    return g.neo4j_db

def close_db(error):
Beispiel #22
from flask import Flask, redirect, render_template, url_for
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SECRET_KEY'] = 'Development Key'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
db = SQLAlchemy(app)

class Team(db.Model):
	name = db.Column(db.String, primary_key=True)
	seed = db.Column(db.Integer)
	region = db.Column(db.string)

	def __init__(self,name,seed,region): = name
		self.seed = seed
		self.region = region

	def __repr__(self):
		return '{0.seed}. {} ({0.region} Region)'.format(self)

def index():
	for region in ['Midwest', 'West', 'South', 'East']:
		teams = Team.query.filter_by(region=region).all()
		print region
		print teams
		page.append('<h1>' + region + '</h1>')
		for team in teams:
Beispiel #23
from flask import Flask, render_template, session, redirect, url_for
from flask.ext.socketio import SocketIO, emit, disconnect
from flask.ext.bootstrap import Bootstrap
from import Form
from wtforms import StringField, SubmitField
from wtforms.validators import Required

app = Flask(__name__)
app.config['SECRET_KEY'] = 'test'
ws = SocketIO(app)
bootstrap = Bootstrap(app)
app.debug = True
thread = None

class NickForm(Form):
    name = StringField('Nickname: ', validators=[Required()])
    submit = SubmitField('Set Nickname')

def chat():
    if session.get('nick') != None:
        return render_template('index.html', nickname=session.get('nick'))
        return redirect(url_for('index'))

@app.route('/', methods=['GET', 'POST'])
def index():
    if session.get('nick') != None:
        return redirect(url_for('chat'))
    form = NickForm()
Beispiel #24
from flask import Flask, render_template, request, redirect, flash, \
     url_for, session, escape
from yahoo_finance import Share
from mongoengine import connect
import models, time
from forms import LoginForm, RegisterForm
from flask.ext.mail import Message, Mail

mail = Mail()

app = Flask(__name__);

# secret key is needed for forms(csrf)
app.config['SECRET_KEY'] = 's3cr3t'
# Database to use for mongoDB
app.config['MONGODB_DB'] = 'finance'
app.debug = False
connect(''' Removed for security reasons ''')
app.config["MAIL_SERVER"] = ""
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = #removed for security reasons
app.config["MAIL_PASSWORD"] = #removed for security reasons


def index():
    if 'username' in session:
        return redirect('portfolio')
30th May 2014

# Start with a basic flask app webpage.
from flask.ext.socketio import SocketIO, emit
from flask import Flask, render_template, url_for, copy_current_request_context
from random import random
from time import sleep
from threading import Thread, Event

__author__ = 'slynn'

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
app.config['DEBUG'] = True

#turn the flask app into a socketio app
socketio = SocketIO(app)

#random number Generator Thread
thread = Thread()
thread_stop_event = Event()

class RandomThread(Thread):
    def __init__(self):
        self.delay = 1
        super(RandomThread, self).__init__()

    def randomNumberGenerator(self):
Beispiel #26
from flask import Flask, make_response, flash, request, render_template, redirect, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy.orm.exc import NoResultFound #, MultipleResultsFound
import json, datetime, sys
from flask.ext.uploads import UploadSet, IMAGES, AUDIO, configure_uploads  #

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/charon'  
app.config['SECRET_KEY'] = '123charon456'
db = SQLAlchemy(app)

# Models


class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)  #use email as primary key instead??
    email = db.Column(db.String, unique=True)
    password = db.Column(db.String(64))
    access = db.Column(db.SmallInteger, default = PARENT)

    def validate_email(self, key, address):
        assert '@' in address
        assert '.' in address
        return address