Example #1
0
File: app.py Project: snare/flexo
def create_app(config_dict={}):
    global env, config

    # Set up scruffy environment
    env = Environment(
        dir=Directory('~/.flexo', create=False,
            config=ConfigFile('config', defaults=File('default.conf', parent=PackageDirectory()), apply_env=True)
        )
    )
    config = env.config

    # Setup flask app
    app = Flask(__name__, static_url_path='/static')
    app.secret_key = config.secret
    app.config["MONGODB_SETTINGS"] = {'host': config.db_uri}
    app.config.update(config_dict)
    app.register_blueprint(main)

    # Setup database
    app.db = MongoEngine(app)

    # Setup login_manager
    login_manager.init_app(app)
    login_manager.login_view = 'login'

    # Setup API
    api = Api(app)
    api.add_resource(MetricAPI, '/api/metric')
    api.add_resource(ExerciseAPI, '/api/exercise')

    # Make sure there's at least an admin user
    if len(User.objects) == 0:
        User(name='admin', password='admin').save()

    return app
Example #2
0
def create_app(config=None, environment=None):
    app = Flask(__name__)

    # TODO: Get this from a config file
    app.config["MONGODB_SETTINGS"] = {'db': "eatdb"}
    app.config[
        "SECRET_KEY"] = "\x1a\xb1\x9d\x1d\xf2\x01\xa1X\xb8g\xed\x1c\xb3\x0f+s\xbce\xf6\x92\x83'\xf2\xbc\x96\xc6\x18\x03`\xc0\x0c("
    app.config["IV"] = '\xe7\x9d\xc7\xbd\x12l\x88\xc7\xe9D\x93!\xa2B\xed\x91'
    app.config.from_pyfile('settings.cfg', silent=True)
    app.session_interface = MongoSessionInterface(**(app.config["MONGODB_SETTINGS"]))

    with app.app_context():
        from models import db
        db.init_app(app)

        login_manager = LoginManager()

        @login_manager.user_loader
        def load_user(id):
            if id in (None, 'None'):
                return None
            try:
                from models.user import User
                return User.objects(id=id).first()
            except:
                return None

        login_manager.init_app(app)

        from views import register_routes as register_views

        register_views(app)

    return app
Example #3
0
def create_app():
	from flask import Flask, render_template
	from flask.ext.httpauth import HTTPBasicAuth
	from flask.ext.mongoengine import MongoEngine
	from flask_debugtoolbar import DebugToolbarExtension
	from v1.models import db
	#start the app
	app = Flask(__name__)
	#Load up the config
	app.debug=True
	app.port="8080"
	app.host="0.0.0.0"
	#app.config.from_pyfile('config')
	app.config["MONGODB_SETTINGS"]={
		"db":"deploy",
		"host":"0.0.0.0",
		"port":27017
	}
	app.config["SECRET_KEY"]="secretkey"
	app.config["DEBUG_TB_ENABLED"]=True
	#bootstrap the database
	db.init_app(app)
	#bootstrap everything else
	#auth = HTTPBasicAuth()
	toolbar=DebugToolbarExtension(app)

	from v1.routes import blueprint as DeployApi
	app.register_blueprint(DeployApi)
	
	print app.url_map
	return app
Example #4
0
def setup():
    app = Flask(__name__)
    app.config["SECRET_KEY"] = "1"
    app.config["CSRF_ENABLED"] = False
    app.config["MONGODB_SETTINGS"] = {"DB": "tests"}

    db = MongoEngine()
    db.init_app(app)

    admin = Admin(app)

    return app, db, admin
Example #5
0
File: app.py Project: lita/opendoor
def create_app():
    app = Flask(__name__)

    app.config["MONGODB_SETTINGS"] = {
        "host": getenv("MONGOLAB_URI", None),
    }
    app.config["SECRET_KEY"] = "KeepThisS3cr3t"

    app.register_blueprint(blueprint)

    db.init_app(app)

    return app
Example #6
0
def create_app(**config_overrides):
    app = Flask(__name__, static_folder='static', static_url_path='')

    # Load config.
    app.config["MONGODB_SETTINGS"] = {'DB': "my_zillow_db"}
    # apply overrides
    app.config.update(config_overrides)

    # Setup the database.
    db.init_app(app)

    # Register blueprints
    from views import zillow_app
    app.register_blueprint(zillow_app)

    return app
Example #7
0
def create_app():

    new_app = Flask(__name__)

    new_app.config["MONGODB_SETTINGS"] = {
        'db': 'locations',
        'host': os.getenv('MONGODB_URI', 'localhost')
    }

    new_app.config["SECRET_KEY"] = os.getenv('LOCAL_KEY', "KeepThisS3cr3t")

    db = MongoEngine(new_app)
    Location = location_model.factory(db)

    new_app.register_blueprint(locations_routes.locations)
    locations_routes.Location = Location

    return new_app
Example #8
0
def create_app():
    app = Flask(__name__)
    app.config["MONGODB_SETTINGS"] = {'DB': "MMCS_survey"}
    app.config["SECRET_KEY"] = ""

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .survey import survey as survey_blueprint
    app.register_blueprint(survey_blueprint,  url_prefix='/survey')

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .maintaining import maintaining as maintaining_blueprint
    app.register_blueprint(maintaining_blueprint, url_prefix='/maintaining')

    return app
Example #9
0
def create_app(config=None):
    if not config:
        config = {
            'db': 'testproject',
            'host': '127.0.0.1',
            'port': 27017,
            'read_preference': read_preferences.ReadPreference.PRIMARY,
        }

    app = Flask(__name__)
    app.config["MONGODB_SETTINGS"] = config

    db.init_app(app)

    from api.views import api as api_blueprint
    app.register_blueprint(api_blueprint)

    return app
Example #10
0
def create_app(config={'MONGODB_SETTINGS': {'DB': "assignment"}}):
    app = Flask(__name__)
    app.config["MONGODB_SETTINGS"] = config['MONGODB_SETTINGS']
    app.register_blueprint(api)
    db.init_app(app)
    return app
from flask import Flask, render_template, request, jsonify

from flask.ext.mongoengine import MongoEngine

import json
from datetime import datetime
from gcm import GCM

app=Flask(__name__,template_folder="common",static_folder="common",static_url_path="")

app.config["MONGODB_SETTINGS"]={'db' : "PushNotificationsDB"}
db = MongoEngine(app)



class Subscriptions(db.Document):
	registrationId = db.StringField(max_length = 1000, required = True)
	subscriptionList = db.ListField(default=[])
	pushAllowed = db.StringField(default="true")

class Notifications(db.Document):
	notificationTitle = db.StringField(required =True)
	notificationBody = db.StringField(max_length = 1000)
	registrationIds = db.ListField(db.StringField(max_length=1000))



@app.route('/')
def initialiseTemplate():
	return render_template('notificationPanel.html')
    
Example #12
0
# Import flask and template operators
from flask import Flask, render_template
from flask.ext.mongoengine import MongoEngine

# Define the WSGI application object
app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {'DB': "socomp"}
app.config["SECRET_KEY"] = "KeepThisS3cr3t@sK3Y"

db = MongoEngine(app)

# Sample HTTP error handling
@app.errorhandler(404)
def not_found(error):
    return render_template('404.html'), 404

@app.route('/')
def index():
	return render_template('base.html')

from app.mod_trends.controllers import mod_trends as mod_trends
from app.mod_expert_prediction.controllers import mod_expert_prediction as mod_expert_prediction
from app.mod_response_time.controllers import mod_response_time as mod_response_time

# Register blueprint(s)
app.register_blueprint(mod_trends)
app.register_blueprint(mod_response_time)
app.register_blueprint(mod_expert_prediction)
Example #13
0
#!/usr/bin/env python
import os
from flask import Flask, render_template, jsonify, request
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)

#####################################################################
# Check if running locally on on Heroku and setup MongoDB accordingly
#####################################################################
app.config["MONGODB_SETTINGS"] = {
    'DB': 'my_app'
}
app.config["SECRET_KEY"] = "asdjhfa87sdfas78df"  # used for csrf forms

on_heroku = False
if 'MONGOLAB_URI' in os.environ:
  on_heroku = True

if on_heroku:
    app.config["MONGODB_SETTINGS"]["host"] = os.environ['MONGOLAB_URI']
else:
    app.config["MONGODB_SETTINGS"]["host"] = 'mongodb://localhost:27017/'  # not necessary

db = MongoEngine(app)

#####################################################################
# Models
#####################################################################
from models.post_model import *
from flask import Flask, render_template
from flask.ext.mongoengine import MongoEngine


# make app
app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {'DB': "architect_test"}
app.config["SECRET_KEY"] = "KeeafdsfdasdsfapThisdfadfdfadfsaS3cr3t"

db = MongoEngine(app)

@app.route('/')
def index():
    return render_template('index.html', STATIC_URL='/static/')

if __name__ == '__main__':
    app.run()
from flask import Flask,request
from flask import render_template
from flask import jsonify
from flask.ext.mongoengine import MongoEngine
from pymongo import read_preferences
from flask.ext.mongoengine.wtf import model_form
import json
import libvirt
import os
import sys

app = Flask(__name__)

app.config["MONGODB_SETTINGS"] = {'DB': "test",'read_preference': read_preferences.ReadPreference.PRIMARY}
db = MongoEngine(app)

#### MongoDB Classes ####

class Vm(db.Document):
	name = db.StringField(required=True)
	instance_type = db.StringField(required=True)
	image_id = db.StringField(required=True)
	vmid = db.StringField(required=True)
	pmid = db.StringField(required=True)
	pm = db.StringField(required=True)

#### Global Variables ####
image_paths = []
pm_paths = []
pm_next = 0
Example #16
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine


app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {'DB': "Inn"}
app.config["SECRET_KEY"] = "22 67 67 4a 2a 4a"

db = MongoEngine(app)

def register_blueprints(app):
    # Prevents circular imports
    from Inn.views import posts
    app.register_blueprint(posts)

register_blueprints(app)

if __name__ == '__main__':
    app.run()
Example #17
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine


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

db = MongoEngine(app)

def register_blueprints(app):
    # Prevents circular imports
    from views import posts
    from admin import admin
    app.register_blueprint(posts)
    app.register_blueprint(admin)


register_blueprints(app)



if  __name__ == '__main__':
	app.run()
from flask import Flask

from flask.ext.mongoengine import MongoEngine

from mongoengine import *
from flask import render_template,request

from models import Details,db
from pymongo import read_preferences


application=Flask(__name__)
application.config["MONGODB_SETTINGS"]={'db':'projectB'}

application.secret_key="akshaynathrprojectB"

db.init_app(application)
def _sort(Data):
	words=Data.split()
	return words


@application.route('/home')
@application.route('/')

def home():
	return render_template("Home.html")

@application.route('/home',methods=["POST"])
@application.route('/',methods=["POST"])
def Search():
Example #19
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {'DB': "datasamalen"}
app.config["SECRET_KEY"] = "KeepThisS3cr3t"
app.debug = True

db = MongoEngine(app)

if __name__ == '__main__':
    app.run()

def register_blueprints(app):
    # Prevents circular imports
    from datasamalen.views import devices
    app.register_blueprint(devices)

register_blueprints(app)

Example #20
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {
    'DB': 'IbmCloud_g3ju9m4v_86a7e4d1',
    'host': 'ds041190.mongolab.com',
    'port':  41190,
    'username':'akakoudakis',
    'password': 'kousesro'
}
app.config["SECRET_KEY"] = "KeepThisS3cr3t"



db = MongoEngine(app)


def register_blueprints(app):
    # Prevents circular imports
    from tumblelog.views import posts
    from tumblelog.admin import admin
    app.register_blueprint(posts)
    app.register_blueprint(admin)

register_blueprints(app)

if __name__ == '__main__':
    app.run()
Example #21
0
# db import
from datetime import datetime
from flask.ext.mongoengine import MongoEngine

# admin import
from flask_admin.contrib.mongoengine import ModelView
import flask_admin as admin
from flask_admin.form import rules

# navigation import
from flask.ext.navigation import Navigation


app = Flask(__name__)

app.config["MONGODB_SETTINGS"] = {'DB': "mng_oilbase"}
app.config["SECRET_KEY"] = "password"

# db part 

db = MongoEngine()
db.init_app(app)

class Descriptions(db.Document):
	__tablename__ = "Описания"
	title = db.StringField(max_length=255, required=True)
	description = db.StringField(required=True)
	image = db.ListField(db.StringField(max_length=100))

class Slogans(db.Document):
	__tablename__ = "Слоганы"
Example #22
0
from flask import Flask
from flask.ext.restful import Api
from flask.ext.mongoengine import MongoEngine
from flask.ext.login import LoginManager

app=Flask(__name__)
api=Api(app)
login_manager=LoginManager()
login_manager.init_app(app)
app.config["MONGODB_SETTINGS"] = {'DB': "test_database"}
app.config["SECRET_KEY"] = "qwertyuiop"

db = MongoEngine(app)
# # app.config.from_object('config')

# # from app import views, models
Example #23
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {"DB": "my_tumble_log"}
app.config["SECRET_KEY"] = "KeepThisS3cr3t"

db = MongoEngine(app)


def register_blueprints(app):
    # Prevents circular imports
    from appstore.views import posts
    # from tumblelog.admin import admin
    app.register_blueprint(posts)
    # app.register_blueprint(admin)

register_blueprints(app)

if __name__ == '__main__':
    app.run()
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {"DB": "Mongo_Integration_Demo"}
app.config["SECRET_KEY"] = "InsecurePassword"

def register_blueprints(app):
    from MongoIntegration.views import clothes
    app.register_blueprint(clothes)

register_blueprints(app)
db = MongoEngine(app)

if __name__ == '__main__':
    app.run()

Example #25
0
# oid = OpenID(app, os.path.join(BASE_DIR, 'tmp'))
####### User Login Hack ENDS

# Configurations
app.config.from_object('config')

# Define the database object which is imported
# by modules and controllers
#db = SQLAlchemy(app)
# # Build the database:
# # This will create the database file using SQLAlchemy
# db.create_all()

app.config["MONGODB_SETTINGS"] = { 
    "DB": os.environ.get("FLASK_DB"),
    "USERNAME": os.environ.get("FLASK_USER"),
    "PASSWORD": os.environ.get("FLASK_PASS"),
    "HOST": "127.0.0.1",
    "PORT": 27017 }
db = MongoEngine(app)

def install_secret_key(app, filename='secret_key'):
    """Configure the SECRET_KEY from a file
    in the instance directory.

    If the file does not exist, print instructions
    to create it from a shell with a random key,
    then exit.
    """
    filename = os.path.join(app.instance_path, filename)

    try:
Example #26
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.mail import Mail
from flask.ext.login import LoginManager
from flask.ext.security import Security, MongoEngineUserDatastore, \
    UserMixin, RoleMixin, login_required

app = Flask(__name__)

app.config['DEBUG'] = True

app.config["MONGODB_SETTINGS"] = {'DB': "howler"}
app.config["SECRET_KEY"] = "KeepThisS3cr3t"

app.config["SECURITY_REGISTERABLE"] = True
app.config["SECURITY_SEND_REGISTER_EMAIL"] = False

db = MongoEngine(app)

def register_blueprints(app):
    # Prevents circular imports
    from project.views import users
    app.register_blueprint(users)
    from project.views import howls
    app.register_blueprint(howls)
    from project.views import auth
    app.register_blueprint(auth)
    from project.views import pack
    app.register_blueprint(pack)

register_blueprints(app)
Example #27
0
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 22 17:11:33 2014

@author: Yunus
"""

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

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

db = MongoEngine(app)

if __name__ == '__main__':
    app.run()
Example #28
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

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

db = MongoEngine(app)

if __name__ == '__main__':
    app.run()
Example #29
0
#!/usr/bin/python

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

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {"db":"dexter-api"}
db = MongoEngine(app)

class Usuarios(db.Document):
    nome = db.StringField()
    email = db.StringField(unique=True)
    data_cadastro = db.DateTimeField(defaults=datetime.datetime.now())

class Grupos(db.Document):
    nome = db.StringField(unique=True)
    integrantes = db.ListField()

if __name__ == '__main__':
    u = Usuarios()
    u.nome = "Maria2"
    u.email = "maria2@4linux.com.br"
    u.save()
    g = Grupos()
    g.nome = "Comercial"
    g.integrantes.append(u)
    g.save()
    print "Grupo cadastrado com sucesso"
    
Example #30
0
File: main.py Project: maxziv/SEApp
# from flask_mail import Mail
# # After 'Create app'
# app.config['MAIL_SERVER'] = 'smtp.gmail.com'
# app.config['MAIL_PORT'] = 465
# app.config['MAIL_USE_SSL'] = True
# app.config['MAIL_USERNAME'] = 'yale.hout@gmail.com'
# app.config['MAIL_PASSWORD'] = 'yalese14'
# mail = Mail(app)


# Flask Configuration goes here
# http://pythonhosted.org/Flask-Security/configuration.html
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False

# MongoDB Configuration goes here
app.config["MONGODB_SETTINGS"] = {'DB': "yalehout", "host":'mongodb://yalehout:qwe123@ds063307.mongolab.com:63307/yalehout'}
# if localhost - make sure you start the daemon first - mongod
# app.config['MONGODB_DB']='test'
# app.config['MONGODB_HOST']='127.0.0.1'
# app.config['MONGODB_PORT']=27017
db = MongoEngine(app)



class Role(db.Document, RoleMixin):
    name = db.StringField(max_length=80, unique=True)
    description = db.StringField(max_length=255)
    
    #above is the minimum, dont touch

#http://pythonhosted.org/Flask-Security/customizing.html