Example #1
0
def createHerokuDb():
	"""
	Import this function and the database models into 'heroku run python' to create database on heroku
	"""
		app = Flask(__name__)
		app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['dbUrl']
		db = SQLAlchemy(app)
		db.create_all()
Example #2
0
def create_app():
    app = Flask("test", template_folder=basedir + "/../app/templates")
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'opinionated-test.db')
    app.config['SERVER_NAME'] = 'localhost:5000'
    app.debug = True
    db.app = app
    db.init_app(app)
    return app
def create_app(database_uri=''):                                                                                                                 
    app = Flask(__name__)
    app.config.from_object(config)

    # overrides if passed in
    if database_uri:
        app.config['SQLALCHEMY_DATABASE_URI'] = database_uri

    login_manager.setup_app(app)
    db.init_app(app)
    app.register_blueprint([APPNAME])

    return app
Example #4
0
def create_app(config_object=ProdConfig):
    """An application factory, as explained here:
        http://flask.pocoo.org/docs/patterns/appfactories/

    :param config_object: The configuration object to use.
    """
    app = Flask(__name__)
    app.config.from_object(config_object)

    if config_object == ProdConfig:
        app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL']

    register_extensions(app)
    register_blueprints(app)
    register_errorhandlers(app)
    return app
Example #5
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = CONF.database.connection

    filters.init_app(app)
    {% if plugin.flask_sqlalchemy -%}
    db.init_app(app)
    {% if plugin.flask_admin -%}
    db_admin.init_app(app)
    admin.init_app(app)
    {% endif -%}
    {% endif -%}

    # app.register_blueprint(blueprint)
    # admin.add_view(adminview)

    return app
Example #6
0
"""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 <damien.mathieu@adthink-media.com>
"""
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'
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

# 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)
from flask import Flask
from flask_sqlalchemy import SQLAlchemy 
from datetime import datetime
import os
basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, './dbTest.db')
session_options = {'autocommit': False, 'autoflush': False}
db = SQLAlchemy(app, session_options=session_options)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)
    pub_date = db.Column(db.DateTime)

    def __init__(self, username, email, pub_date):
        self.username = username
        self.email = email
        self.pub_date = pub_date

    def __repr__(self):
        return '<User %r>' % self.username

db.drop_all()
db.create_all()

admin = User('admin', 'admin@example.com', datetime(2015, 6, 5, 8, 10, 10, 10))
guest1 = User('guest1', 'guest1@example.com', datetime(2015, 6, 5, 10, 20, 10, 10))
Example #8
0
from flask import Flask, render_template, request, redirect, url_for
from flask.ext.sqlalchemy import SQLAlchemy, BaseQuery
from datetime import datetime, date
from pprint import pprint

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:root@localhost:3306/e_lagyan_distribution'
db = SQLAlchemy(app)

class Account(db.Model):
    __tablename__ = 'account'

    mobile_number = db.Column(db.String(11), primary_key=True)
    account_pin = db.Column(db.Integer)
    owner_name = db.Column(db.String(256))
    account_type = db.Column(db.String(10))
    status = db.Column(db.String(10))
    balance = db.Column(db.Integer)
    balance_limit = db.Column(db.Integer)

class BalanceInquiryRequest(db.Model):
    __tablename__ = 'balance_inquiry_request'

    transaction_id = db.Column(db.Integer, primary_key=True)
    balance = db.Column(db.Integer)

class BalanceTransferRequest(db.Model):
    __tablename__ = 'balance_transfer_request'

    transaction_id = db.Column(db.Integer, primary_key = True)
from flask import Flask, request
from flask.ext.sqlalchemy import SQLAlchemy
from sentiment_analyzer import sentiment
import matplotlib.pyplot as plt

app = Flask(__name__)
db = SQLAlchemy(app)

app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:root@localhost/scriptures'

class Verse(db.Model):
    __tablename__ = 'verses'
    id = db.Column(db.Integer, primary_key=True)
    scripture_text = db.Column(db.String)
    polarity = db.Column(db.Integer)
    chapter_id = db.Column(db.Integer, db.ForeignKey('chapter.id'))

class Chapter(db.Model):
    __tablename__ = 'chapters'
    id = db.Column(db.Integer, primary_key=True)
    chapter_number = db.Column(db.Integer)
    # book_id = db.Column(db.Integer, db.ForeignKey('book.id'))
    # verses = db.relationship('Verse', backref='chapter',
                                # lazy='select')

class Book(db.Model):
    __tablename__ = 'books'
    id = db.Column(db.Integer, primary_key=True)
    book_title = db.Column(db.String)
    book_long_title = db.Column(db.String)
    book_subtitle = db.Column(db.String)
from flask.ext.admin.contrib import sqla

from wtforms.fields import PasswordField

# Initialize Flask and set some config values
app = Flask(__name__)
app.config['DEBUG']=True
# 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.
#xxxxx
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.
# It uses Flask-Mail behind the scenes.
# Set mail-related config values.
# Replace this with your own "from" address
app.config['SECURITY_EMAIL_SENDER'] = 'no-reply@example.com'
# Replace the next five lines with your own SMTP server settings
app.config['MAIL_SERVER'] = 'email-smtp.us-west-2.amazonaws.com'
app.config['MAIL_PORT'] = 465
Example #11
0
from flask import Flask
from flaskext.sqlalchemy import SQLAlchemy

from settings import local
import locale

locale.setlocale(locale.LC_ALL, 'de_DE.utf8')

app = Flask("app_name")
db_url = '%s://%s:%s@%s/%s' % (
        local.ENGINE, 
        local.USERNAME, 
        local.PASSWORD, 
        local.HOST, 
        local.DATABASE
        )
app.secret_key = '7104f3435f6dae99bb2ec4cdd903a90d'
app.config['SQLALCHEMY_DATABASE_URI'] = db_url
app.config['CSRF_ENABLED'] = False
db = SQLAlchemy(app)


from views import *
Example #12
0
from flask.ext.bootstrap import Bootstrap

from flask.ext.sqlalchemy import SQLAlchemy
import pika

from pika.exceptions import AMQPConnectionError

from message_handler import handle_msg
from settings import SQLITE_TEST_DB

app = Flask(__name__)
Bootstrap(app)
QUEUES = ['sensors']
EXCHANGES = [{"name": 'logs', "type": 'fanout'}]
logging.basicConfig()
app.config['SQLALCHEMY_DATABASE_URI'] = SQLITE_TEST_DB
db = SQLAlchemy(app)


def queue_callback(ch, method, properties, body):
    print " [x] Received %r" % (body,)
    message = json.loads(body)
    try:
        msg = handle_msg(message)
        if msg is not False:
            db.session.add(msg)
            db.session.commit()
        else:
            print("error on msg")
    except Exception:
        raise
Example #13
0
File: main.py Project: jackij/FPWeb
  level=logging.DEBUG,
  )
log = logging.getLogger('neuropost')
log.info('Starting neuropost')
from flask import Flask
from database import db
from login_stuff import login_manager, oid
from urls import everything
from database import MYSQL_CONN
from sooper_sekrit import MYSQL_CONN_INFO, sekrit


TESTING = True


app = Flask(__name__)
app.secret_key = sekrit
app.config['SQLALCHEMY_DATABASE_URI'] = MYSQL_CONN % MYSQL_CONN_INFO
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
app.config['SQLALCHEMY_POOL_RECYCLE'] = 60 * 60 # Once an hour.
app.debug = TESTING

db.init_app(app)
login_manager.setup_app(app)
oid.init_app(app)


for urls in everything:
  log.info('Mapping URLs')
  urls(app)
  log.info('Mapping URLs finished.')
Example #14
0
import json
from flask import send_from_directory

try:
    import pygments
    from pygments.formatters import HtmlFormatter
except ImportError:
    pygments = None

app = Flask(__name__)
app.config.from_object('settings')
app.config.from_object('db')
app.secret_key = app.config["SECRET_KEY"]
tmpdb = app.config['DATABASE_URI']
#print os.environ[tmpdb]
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ[tmpdb]
UPLOAD_FOLDER = 'uploads/'
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['USE_FAVICON'] =  os.path.exists(os.path.join(app.static_folder, "favicon.ico"))
app.debug = True

db = SQLAlchemy(app)
cache_directory = os.path.dirname(__file__)
try:
    cache = FileSystemCache(os.path.join(cache_directory, "cache"))
except Exception, e:
    print "Could not create cache folder, caching will be disabled."
    print "Error: %s" % e
    cache = NullCache()
Example #15
0
import json

from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:Domsia2016@localhost:3306/myportrait'
db = SQLAlchemy(app)

class Labels(db.Model):
	__tablename__ = 'labels'
	contents = db.Column(db.String(100), primary_key=True)
	labelId = db.Column(db.Integer)
	title = db.Column(db.String(40))
	createUserId = db.Column(db.String(100))
	createtimestamp = db.Column(db.)
		
class AbilityLevel(db.Model):
	__tablename__ = 'abilityLevel'
	id = db.Column(db.Integer, primary_key=True)
	userId = db.Column(db.String(100), unique=True)
	username = db.Column(db.String(100), unique=False)
	labelId = db.Column(db.String(100))
	labelLevel = db.Column(db.Integer)

	def __init__(self, userId, username, labelId, labelLevel):
		self.userId = userId
		self.username = username
		self.labelId = labelId
		self.labelLevel = labelLevela
Example #16
0
'''
Small-Example: email is shown as a link to the edit view of the record.
    http://stackoverflow.com/questions/17174707/can-model-views-in-flask-admin-hyperlink-to-other-model-views
'''
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):
        return self.email
        
class uAdmin(sqla.ModelView):

    def _user_formatter(view, context, model, name):
        return Markup(
import os

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

basedir = os.path.abspath(os.path.dirname(__file__))

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL',
                                                       'postgresql://vagrant:vagrant@127.0.0.1/vagrant')
app.config['SQLALCHEMY_MIGRATE_REPO'] = os.path.join(basedir, 'migrations')
db = SQLAlchemy(app)


from apps.account import models


@app.route('/')
def hello():
    return 'Hello World!'
Example #18
0
# -*- coding: utf-8 -*-
"""`main` is the top level module for your Flask application."""

# Reference: https://console.developers.google.com/sql/instances/cs8-mysql-db/overview?project=cs8-databases&duration=PT1H
# ^^ might need to use their API's -- see link to "How to Connect to your Cloud SQL Instance"


# TODO: PUT THIS IN A STATIC CONFIG FILE
DB_IP_ADDR = '2001:4860:4864:1:1392:af72:fd23:d9fd'

# Import the Flask Framework
from flask import Flask
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = ('mysql://master:@%s/cs8-mysql-db' % DB_IP_ADDR)
db = SQLAlchemy(app)
# Note: We don't need to call run() since our application is embedded within
# the App Engine WSGI application server.

import jinja2
import webapp2


JINJA_ENVIRONMENT = jinja2.Environment(
    loader=jinja2.FileSystemLoader(os.path.dirname(__file__)),
    extensions=['jinja2.ext.autoescape'],
    autoescape=True)


######################################################################

# Shakespeare Table
Example #19
0
from yoi.flask_genshi import Genshi, render_response
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)

app.register_blueprint(account)

# 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'),
]
Example #20
0
from flask import Flask, render_template, flash, session, redirect, url_for
from flask.ext.bootstrap import Bootstrap
from flask.ext.wtf import Form
from wtforms import StringField, SubmitField 
from wtforms.validators import Required
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Shell, Manager
from flask,ext.mail import Mail

app = Flask(__name__)
app.config['SECRET_KEY'] = 'hard to guess string'
app.config['SQLALCHEMY_DATABASE_URI'] =\
    'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
db = SQLAlchemy(app)
bootstrap = Bootstrap(app)
manager = Manager(app)

# mail
app.config['MAIL_SERVER'] = 'smtp.googlemail.com' 
app.config['MAIL_PORT'] = 587
app.config['MAIL_USE_TLS'] = True 
app.config['MAIL_USERNAME'] = os.environ.get('MAIL_USERNAME') 
app.config['MAIL_PASSWORD'] = os.environ.get('MAIL_PASSWORD')
mail = Mail(app)


# form
class NameForm(Form):
    name = StringField('What is your name?', validators=[Required()]) 
    submit = SubmitField('Submit')
Example #21
0
from flask import Flask, request, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
from sqlalchemy import and_, between
import math
import os

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'os.environ['DATABASE_URL']
db = SQLAlchemy(app)


class Listing(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    street = db.Column(db.String(30))
    status = db.Column(db.String(7))
    price = db.Column(db.Integer)
    bedrooms = db.Column(db.Integer)
    bathrooms = db.Column(db.Integer)
    sqft = db.Column(db.Integer)
    lat = db.Column(db.Float)
    lng = db.Column(db.Float)


@app.route('/')
def hello_world():
    """to test app is running"""
    return "hello world!"


@app.route('/listings')
def get_listings():
############################
#### Iniciamos la app  #####
############################
app = Flask(__name__)
app.debug = True

version='v0.5'  #20 Febrero 2015

############################
############################


################################
# Configuracion DATABASE HEROKU
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ["DATABASE_URL"]
db = SQLAlchemy(app)

# TABLA CANALES: definicion
class Canales(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    nombre = db.Column(db.String(255))
    ip = db.Column(db.String(255))
    port = db.Column(db.String(255))
    numcanal = db.Column(db.String(255))
    nombrecorto = db.Column(db.String(255))

    def __init__(self, nombre, ip,port,numcanal,nombrecorto):
        self.nombre = nombre
        self.ip = ip
        self.port = port
Example #23
0
from flask import Flask, request, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
import json

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///Medidas.db'
db = SQLAlchemy(app)
from model import *

@app.route('/')
def index():
	return "Hello Sheldon. Para corrigir nosso trabalho sem problemas, nossas rotas sao [/mostrar], [/estufa/new], [/medidas/new]!!"
	
@app.route('/mostrar', methods = ['GET'])
def mostraValores():
    medidas = []
    for i in Medida.query.all():
        print i.id,i.estufa_id, i.temperatura,i.umidade
        medidas.append({'id': i.id, 'estufa_id': i.estufa_id, 'temperatura':i.temperatura, 'umidade':i.umidade})
    return	json.dumps(medidas)

@app.route('/estufa/new', methods = ['POST'])
def estufa_new():
	if not request.json:
		return jsonify({'status': False})
    p = request.get_json()
	a = Estufa()
	a.localizacao = p['localizacao']
	db.session.add(a)
	db.session.commit()
	return jsonify({'status': True})
Example #24
0
from flask import Flask, jsonify, request
from flask_sqlalchemy import SQLAlchemy
from user import User
from werkzeug.serving import run_simple
from quick_json import QuickJson
from project import Project
import database
import json
app = Flask(__name__)

# TODO: Look at first link under resources for more information

# Setup Database
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://vitesse:asd123@127.0.0.1/vitesse'
database.db = SQLAlchemy(app)


""" POST """


@app.route("/user", methods=["POST"])
def create_user():
    if request.data:
        try:
            payload = json.loads(request.data)
            email = payload["email"]
            username = payload["username"]
            password = payload["password"]
            existing_user = User.query.filter_by(email=email).first()
            if existing_user is None:
                new_user = User(email, username, password)
Example #25
0
import __builtin__
from flask import Flask, render_template, request
from flask.ext.sqlalchemy import SQLAlchemy

application = Flask(__name__)
application.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///ksc.db'
__builtin__.ksc_db = SQLAlchemy(application)

from manage_user import *


@application.route("/")
def home():
    return render_template("home.html")


@application.route("/aboutus")
def about_us():
    return render_template("aboutus.html")


@application.route("/contactus")
def contact_us():
    return render_template("contactus.html")


@application.route("/events")
def events():
    return render_template("events.html")

Example #26
0
import cloudinary
import cloudinary.api
import cloudinary.uploader

cloudinary.config(
  cloud_name = 'university-of-colorado',  
  api_key = '893246586645466',  
  api_secret = '8Liy-YcDCvHZpokYZ8z3cUxCtyk'  
)

import json
import psycopg2

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgres://iovivwytcukmgi:cdigSG1Zx3Ek_ANVRbSAN1r0db@ec2-174-129-197-200.compute-1.amazonaws.com:5432/d660ihttvdl1ls'
Bootstrap(app)

db = SQLAlchemy(app)

class User(db.Model):
    uid = db.Column(db.BigInteger, primary_key=True)
    name = db.Column(db.String(80), unique=False)
    avatarName = db.Column(db.String(80), unique=False)

    #notes = relationship("Note", order_by="Note.uid", backref="user")

    def __init__(self, uid, name, avatarName):
    	self.uid = uid
        self.name = name
        self.avatarName = avatarName
Example #27
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db'
db = SQLAlchemy(app)

class SubSet(db.models):
	'''A subset of items'''
	
	id = db.Column(db.Integer, primary_key=True)
	name = db.Column(db.String(80), nullable = False)
	picture_path = db.Column(db.String(2000))
	set_id = db.Column(db.Integer, db.ForeignKey('set.id'), nullable = False)
	
	set = db.relationship('Set', backref=db.backref('subsets', lazy='dynamic'))
	
	def __init__(self, name, set, picture_path = None) :
		self.name = name
		self.set = set
		self.picture_path = picture_path
		
class Item(db.models):
	'''An item'''
	
	id = db.Column(db.Integer, primary_key=True)
	name = db.Column(db.String(80), nullable = False)
	subset_id = db.Column(db.Integer, db.ForeignKey('subset.id'), nullable = False)
	price_id = db.Column(db.Integer, db.ForeignKey('price.id'))
	picture_path = db.Column(db.String(2000))
	ingredients = db.Column(db.Text)
Example #28
0
from flask import Flask
 
app = Flask(__name__)
 
app.secret_key = 'development key'
 
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = 'contact@example.com'
app.config["MAIL_PASSWORD"] = 'your-password'
 
from routes import mail
mail.init_app(app)
 
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://evans:evans@localhost/development'
 
from models import db
db.init_app(app)

import flask-sqlalchemy.routes
Example #29
0
from time import time
from email.utils import formatdate

from flask import Flask, redirect
from flask.ext.restless import APIManager
from flask.ext.sqlalchemy import SQLAlchemy


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


@app.route('/')
def index():
    return redirect('/static/index.html')


@app.after_request
def add_header(response):
    response.headers['Cache-Control'] = 's-maxage=86400, max-age=86400'
    response.headers['Expires'] = formatdate(time() + 86400)
    return response


from chronicle.models import Event

manager = APIManager(app, flask_sqlalchemy_db=db)
manager.create_api(
    Event,
    # Exposes the Event models at /api/event
Example #30
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import os, sys

"""def check_environment():
	environment_dependencies = [
		"ENV",
		"DATABASE_URL"
	]
	can_run = True
	for dep in environment_dependencies:
		if dep not in os.environ:
			print "Need environment variable: " + dep + " to be set"
			can_run = False
	if not can_run:
		sys.exit()

check_environment()"""

app = Flask(__name__)
app.secret_key = "u'^z8aXeQ@<Q4z%"
app.config['SQLALCHEMY_DATABASE_URI'] = "postgres://boiler:password@localhost:5432/boilermake"
db = SQLAlchemy(app)

from models import *
from views import *