Example #1
0
def generate_app(
         debug=False, config_file=None, secret="",
         session_secret="",
         github_client_id="", github_client_secret="", github_hook_secret="",
         mongodb_db="Hook", mongodb_host='127.0.0.1', mongodb_port=27017, mongodb_user=None, mongodb_password=None,
         hooktest_secret="", hooktest_remote="http://127.0.0.1:5002/hooktest/rest/api/queue"
    ):
    app = Flask(__name__)
    app.config["JSONIFY_PRETTYPRINT_REGULAR"] = False

    if not config_file:
        app.config["SECRET_KEY"] = session_secret,
        app.config["GITHUB_CLIENT_ID"] = github_client_id
        app.config["GITHUB_CLIENT_SECRET"] = github_client_secret

        app.config["MONGODB_DB"]= mongodb_db
        app.config['MONGODB_HOST'] = mongodb_host
        app.config['MONGODB_PORT'] = mongodb_port

        if mongodb_user:
            app.config['MONGODB_USERNAME'] = mongodb_user
        if mongodb_password:
            app.config['MONGODB_PASSWORD'] = mongodb_password

        app.config["HOOKUI_HOOKTEST_SECRET"] = hooktest_secret
        app.config["HOOKUI_GITHUB_SECRET"] = github_hook_secret
        app.config["HOOKUI_REMOTE"] = hooktest_remote
    else:
        app.config.update(read_yaml(config_file)[0])

    app.debug = debug
    app.config["DEBUG"] = debug
    hook = HookUI(prefix="", app=app)
    return app
Example #2
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

# Create eDisc
app = Flask(__name__)

app.config["SECRET_KEY"] = "super-secret"

# MongoDB Config
app.config["MONGODB_DB"] = "gw_edisc"
app.config["MONGODB_HOST"] = "localhost"
app.config["MONGODB_PORT"] = 27017

# Create mongo database connection object
db = MongoEngine(app)

from gw_edisc import views

if __name__ == "__main__":
    app.run()
Example #3
0
import random
import datetime
import time
from flask import Flask
from flask.ext.mongoengine import MongoEngine

# Seeds the random class with something from the system clock, allowing true random generation
random.seed()

app = Flask(__name__)
app.config["MONGODB_DB"] = "hrv"

db = MongoEngine(app)

class Data(db.Document):
  recorded_at = db.DateTimeField(default=datetime.datetime.now, required=True)
  ibi = db.IntField(min_value=0, max_value=9000, required=True)
  hr = db.IntField(min_value=0, max_value=300, required=True)
  
  meta = {
      'allow_inheritance': True,
      'indexes': ['-recorded_at', 'ibi', 'hr'],
      'ordering': ['-recorded_at']
  }

count = 0
while (count < 100):
  time_measured = datetime.datetime.now() 
  ibi_value = random.randint(800,1200)
  hr_value = random.randint(40,200)
  data = Data(
Example #4
0
from flask import Flask
from flaskext.mongoengine import MongoEngine
#from mongoengine import connect

#enter mongolab credentials here

#connect('flasktest', host='mongodb://'+un+':'+pw+'@ds033877.mongolab.com:33877/flasktest')


app = Flask(__name__)
app.config["MONGODB_DB"] = 'vendorDB'
#app.config["MONGO_HOST"] = 'mongodb://'+un+':'+pw+'@ds033877.mongolab.com:33877/flasktest'

db = MongoEngine(app)

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

register_blueprints(app)


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


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

app = Flask(__name__)
app.config["MONGODB_DB"] = "octo"
app.config["SECRET_KEY"] = "ItsAS3cr3t"

db = MongoEngine(app)


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

register_blueprints(app)

if __name__ == '__main__':
    app.run()
Example #6
0
from flask import Flask
from flask import Blueprint
from mongoengine import connect

app = Flask(__name__)
app.debug = True


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

app.config["MONGODB_DB"] = "app14403725"
connect(
    "app14403725",
    username="heroku",
    password="11adeea8b870f9f3e576bf7c8ffb1ee9",
    host="mongodb://heroku:11adeea8b870f9f3e576bf7c8ffb1ee9@linus.mongohq.com:10077/app14403725",
    port=10077,
)


# email server
app.config["MAILGUN_KEY"] = "key-6w92k3knfasbqkgm8kszgzrlnvs016c9"
app.config["MAILGUN_DOMAIN"] = "app14403725.mailgun.org"


CSRF_ENABLED = True
SECRET_KEY = "teddymonkey"

OPENID_PROVIDERS = [
    {"name": "Google", "url": "https://www.google.com/accounts/o8/id"},
Example #7
0
import os, urlparse
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from mongoengine import connect
from flask.ext.markdown import Markdown

# import settings

app = Flask(__name__)
app.debug = True
app.config["MONGODB_DB"] = "my_tumble_log"
app.config["SECRET_KEY"] = "KeepThisS3cr3t"


Markdown(app)

MONGOLAB_URI = os.environ.get('MONGOLAB_URI')
if MONGOLAB_URI:
    url = urlparse.urlparse(MONGOLAB_URI)
    app.config["MONGODB_SETTINGS"] = {
        'db': url.path[1:],
        'username': url.username,
        'password': url.password,
        'host': url.hostname,
        'port': url.port
    }
    app.config["MONGODB_DB"] = url.path[1:]

# 

# ToDo add markdown support and embed urls
Example #8
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine
import os
app = Flask(__name__)

app.config["MONGODB_DB"] = os.environ["MONGODB_DB"]
app.config["MONGODB_USERNAME"] = os.environ["MONGODB_USERNAME"]
app.config["MONGODB_PASSWORD"] = os.environ["MONGODB_PASSWORD"]
app.config["MONGODB_HOST"] = os.environ["MONGODB_HOST"]
app.config["MONGODB_PORT"] = os.environ["MONGODB_PORT"]
app.config["SECRET_KEY"] = os.environ["SECRET_KEY"]

db = MongoEngine(app)

from smartmarks.fxns import getCss, getJs, getImg
app.jinja_env.globals.update(getCss=getCss, getJs=getJs, getImg=getImg)

import smartmarks.views
import smartmarks.api_views
Example #9
0
login_manager.init_app(app)
login_manager.login_view = 'auth.signin'

@app.before_request
def before_request():
    g.user = current_user



# Configurations
app.config.from_object('config')
app.config.update(testing = True)

# Define the database object which is imported
# by modules and controllers
app.config["MONGODB_DB"] = 'MONGODB_DB'

db = MongoEngine(app)

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

# Import a module / component using its blueprint handler variable (mod_auth)
from app.modules.intro.controllers import mod_intro as intro_module
from app.modules.auth.controllers import mod_auth as auth_module
from app.modules.chat.controllers import mod_chat as chat_module

# Register blueprint(s)
app.register_blueprint(intro_module)
Example #10
0
from mongoengine import connect
from flask.ext.cors import cross_origin, CORS
from flask.ext.mongoengine import MongoEngine
from flask.ext.mongorest import MongoRest
from flask.ext.mongorest.views import ResourceView
from flask.ext.mongorest.resources import Resource
from flask.ext.mongorest import operators as ops
from flask.ext.mongorest import methods

app = Flask(__name__)
app.debug = True
cors = CORS(app)

HOST = 'mongodb://' + settings.USER + ':' + settings.PASSWORD +'@kahana.mongohq.com:' + str(settings.PORT) + '/' + settings.APP,

app.config["MONGODB_DB"] = settings.APP
connect(
        settings.APP,
        username=settings.USER,
        password=settings.PASSWORD,
        host=HOST,
        port=settings.PORT
)

db = MongoEngine(app)
api = MongoRest(app)

@app.route('/')
def index():
    return render_template("index.html")
Example #11
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.mongorest import MongoRest
from flask.ext.bcrypt import Bcrypt
import os

app = Flask(__name__)
app.config.from_pyfile('../config.py')
if os.environ.get("TESTING"):
    app.config["MONGODB_DB"] = 'testing'
else:
    app.config["MONGODB_DB"] = 'uniRec'
bcrypt = Bcrypt(app)
db = MongoEngine(app)
api = MongoRest(app)

from uniRecSys.app import views, models
Example #12
0
#!flask/bin/python

from flask import Flask, render_template, send_from_directory, request
from mongoengine import connect
from flask.ext.mongoengine import MongoEngine
from flask.ext.social import Social, MongoEngineConnectionDatastore
from flask.ext.login import LoginManager
import models
import config

app = Flask(__name__)

app.config["MONGODB_DB"] = config.DB_NAME
app.config["SOCIAL_TWITTER"] = {
    'consumer_key': config.twitter_key,
    'consumer_secret': config.twitter_secret
}
connect(config.DB_NAME, host='mongodb://' + config.DB_USERNAME + ':' + config.DB_PASSWORD + '@' + config.DB_HOST_ADDRESS)

db = MongoEngine(app)
#Social(app, MongoEngineConnectionDatastore(db, models.Connection))

login_manager = LoginManager()
login_manager.init_app(app)

def get_current_question():
    return list(models.Question.objects)[0]

def get_answers(question):
    return models.Answer.objects(question=question)
Example #13
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_DB"] = "bootstrap"
app.config["SECRET_KEY"] = "secret"

db = MongoEngine(app)


def register_blueprints(app):
    # Prevents circular imports
    from main.views import home
    app.register_blueprint(home)

register_blueprints(app)

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

app = Flask(__name__)
"""
app.config["MONGODB_DB"] = "my_tumble_log"
app.config["MONGODB_USERNAME"] = "molsen"
app.config["MONGODB_PASSWORD"] = "shauna"
app.config["MONGODB_HOST"] = "linus.mongohq.com"
app.config["MONGODB_PORT"] = "10038"
#app.config["MONGODB_SETTINGS"] = {"DB": "my_tumble_log"}
#app.config["MONGODB_SETTINGS"] = {'DB': "mongodb://molsen:shauna@linus.mongohq.com:10038/my_tumble_log"}
app.config["SECRET_KEY"] = "KeepThisS3cr3t"
"""
app.config["MONGODB_DB"] = "app12893270"
app.config["MONGODB_USERNAME"] = "molsen"
app.config["MONGODB_PASSWORD"] = "shauna"
app.config["MONGODB_HOST"] = "linus.mongohq.com"
app.config["MONGODB_PORT"] = "10056"
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)
Example #15
0
# this code allows us to import modules inside the lib directory
import sys, os 
sys.path.insert(0, os.path.abspath(".."))

from flask import Flask
from mongoengine import connect
from flask.ext.mongoengine import MongoEngine
from lib import tokens

# init
app = Flask(__name__)
# app.config.from_object('config')
app.debug = True

# db init
app.config["MONGODB_DB"] = 'fillinbox'
connect('fillinbox', host='mongodb://' + tokens.DB_USER + ':' + tokens.DB_PASSWORD + '@' + tokens.DB_HOST_ADDRESS)

db = MongoEngine(app)

from views import *

# twilio init
Example #16
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.csrf import csrf
from flask_oauth import OAuth

app = Flask(__name__, static_folder="static")
app.config["DEBUG"] = True
app.config["SECRET_KEY"] = 'not-secret'

app.config["MONGODB_DB"] = 'confessionsplus'
app.config["MONGODB_HOST"] = 'localhost'
app.config["MONGODB_PORT"] = 27017

app.config["FACEBOOK_APP_ID"] = "328075160635846"
app.config["FACEBOOK_APP_SECRET"] = "36a95cf8babf110ae8b6f7d49c127725"

app.config["SECURITY_REGISTERABLE"] = True

app.config["SECURITY_PASSWORD_HASH"] = "bcrypt"
app.config["SECURITY_PASSWORD_SALT"] = "salty"
app.config["SECURITY_POST_LOGIN"] = "/"
app.config["SECURITY_POST_LOGOUT"] = "/"

oauth = OAuth()
db = MongoEngine(app)
csrf(app)

def register_blueprints(app):
  from views import posts, profile, main, admin
  app.register_blueprint(main)
  app.register_blueprint(posts)
Example #17
0


# Declare and configure application
app = Flask(__name__, static_url_path='/static')
app.config.from_pyfile('local_settings.py')
if app.config['MONGOLAB_URI']:
    from pymongo.uri_parser import parse_uri
    params = parse_uri(app.config['MONGOLAB_URI'])
    app.config['MONGODB_DB'] = params['database']
    app.config['MONGODB_USERNAME'] = params['username']
    app.config['MONGODB_PASSWORD'] = params['password']
    app.config['MONGODB_HOST'] = params['nodelist'][0][0]
    app.config['MONGODB_PORT'] = params['nodelist'][0][1]
else:
    app.config["MONGODB_DB"] = 'tetetetelephone'


db = MongoEngine(app)

def register_blueprints():
    from mmdgot.views import game_blueprint
    app.register_blueprint(game_blueprint)

register_blueprints()


@app.route('/callbacks', methods=['GET', 'POST'])
def callback():
    return ""
Example #18
0
import os
import stripe

from flask_sslify import SSLify

app = Flask(__name__)

env = os.environ.get("FLASK_ENV", "development")
configuration = None
if env == "development":
    app.config["SECRET_KEY"] = config.dev["secret_key"]
    app.config["STRIPE_PUBLISHABLE_KEY"] = config.dev["stripe_publishable_key"]
    stripe.api_key = config.dev["stripe_secret_key"]
    app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 0
    app.config["passwordResetPrefix"] = config.dev["passwordResetPrefix"]
    app.config["MONGODB_DB"] = config.dev["mongodb_db"]
    app.config["SECRET_KEY"] = config.dev["secret_key"]
    app.config["MONGODB_USERNAME"] = config.dev["mongodb_username"]
    app.config["MONGODB_PASSWORD"] = config.dev["mongodb_password"]
    app.config["MONGODB_HOST"] = config.dev["mongodb_host"]
    app.config["MONGODB_PORT"] = config.dev["mongodb_port"]
    app.config["checkoutRedirect"] = config.dev["checkoutRedirect"]
elif env == "production":
    app.config["MONGODB_DB"] = config.production["mongodb_db"]
    app.config["SECRET_KEY"] = config.production["secret_key"]
    app.config["MONGODB_USERNAME"] = config.production["mongodb_username"]
    app.config["MONGODB_PASSWORD"] = config.production["mongodb_password"]
    app.config["MONGODB_HOST"] = config.production["mongodb_host"]
    app.config["MONGODB_HOST"] = config.production["mongodb_host"]
    app.config["MONGODB_PORT"] = config.production["mongodb_port"]
    app.config["STRIPE_PUBLISHABLE_KEY"] = config.production["stripe_publishable_key"]
Example #19
0
from flask import Flask, request, redirect, render_template, url_for, jsonify
import simplejson
from flask.ext.mongoengine import MongoEngine
import time
from types import ModuleType
from itertools import groupby
from mongoengine import Document, ObjectIdField, queryset, StringField, ListField, IntField, FloatField, DateTimeField, EmbeddedDocumentField

app = Flask(__name__)
app.config["MONGODB_DB"] = "tasks"
app.config["SECRET_KEY"] = "KeepThisS3cr3t"

db = MongoEngine(app)

def querySetToMongo(queryset):
    a = list()
    for i in queryset:
        a.append(i.to_mongo())
    for i in a:
        del i['_id']
    return a

class Task(Document):
    created_at = db.FloatField(default=time.time(), required=True)
    title = db.StringField(max_length=255, required=True)
    body = db.StringField(required=True)
    status = db.StringField(required=True)
    task_id = db.SequenceField(required=True)

    def __unicode__(self):
        return self.body
Example #20
0
from flask import Flask, Response, redirect, request
from flask.ext.mongoengine import MongoEngine
import datetime
from flask import url_for
from flask import json
from flask import render_template
import hashlib


app = Flask(__name__)
app.config["MONGODB_DB"] = "blogapp"


db = MongoEngine(app)


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


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


@app.route('/blog/', methods = ['GET'])
def JsonView():
	posts = Blog.objects.limit(100)
	count = len(posts)
	js = "{" + json.dumps("blogs") + ":["
	for post in posts:
Example #21
0
from flask import Flask
from flaskext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_DB"] = 'lilybbs15'
app.secret_key = '\xd38p\xf4\xf2\xe2)o\xa0\xdfR\xf4\xf7Z|@\x1c\xe5\x1a\x8d6\xdfO\xbe'

db = MongoEngine(app)


def register_blueprints(app):
    # Prevents circular imports
    from views import topic
    app.register_blueprint(topic, url_prefix='/topics')

register_blueprints(app)


if __name__ == '__main__':
    app.run()
Example #22
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine
app = Flask(__name__)
app.config["MONGODB_DB"] = "DataRoomba"
app.config["MONGODB_HOST"] = "dharma.mongohq.com"
app.config["MONGODB_PORT"] = 10019
app.config["MONGODB_USER"] = "dataroomba"
app.config["MONGODB_PASS"] = "There is no data"
app.config["SECRET_KEY"] = "KeepThisS3cr3t"

db = MongoEngine(app)

if __name__ == '__main__':
    app.run()
Example #23
0
from flask import Flask
from mongoengine import connect

app = Flask(__name__)
app.debug = True
app.config["SITE_URL"] = 'http://freak-post.herokuapp.com'

app.config["MONGODB_DB"] = 'app14198794'
connect(
    'app14198794',
    username='heroku',
    password='3_GdcuX1W7oH=',
    host='mongodb://heroku:3_GdcuX1W7oH=@alex.mongohq.com:10095/app14198794',
    port=10095
)
Example #24
0
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_DB"] = "flaskfun"
app.config["SECRET_KEY"] = "ILovePandas"

db = MongoEngine(app)

def register_blueprints(app):
    from FlaskFun.views import posts
    app.register_blueprint(posts)

register_blueprints(app)

if __name__ == '__main__':
    app.run()
Example #25
0
# this code allows us to import modules inside the lib directory
import sys, os 
sys.path.insert(0, os.path.abspath(".."))

from flask import Flask
from mongoengine import connect
from flask.ext.mongoengine import MongoEngine
from lib import tokens
import twilio.twiml
from twilio.rest import TwilioRestClient

# init

app = Flask(__name__)
# app.config.from_object('config')
app.debug = True

# db init

app.config["MONGODB_DB"] = 'claremont-sms-db' 
connect('claremont-sms-db', host='mongodb://' + 'evan' + ':' + tokens.DB_PASSWORD + '@' + tokens.DB_HOST_ADDRESS)

db = MongoEngine(app)

from views import *

# twilio init

client = TwilioRestClient(tokens.TWILIO_ID, tokens.TWILIO_TOKEN)
Example #26
0
from flask import Flask, render_template
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_DB"] = "my_tumble_log"
app.config["SECRET_KEY"] = "KeepThisS3cr3t"

db = MongoEngine(app)

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

register_blueprints(app)

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

if __name__ == '__main__':
    app.run()
Example #27
0
DB_HOST_ADDRESS = "ds035127.mongolab.com:35127/soundsgood"

UPLOAD_FOLDER = "data/uploads"
ALLOWED_EXTENSIONS = set(["wav"])

# initialization
app = Flask(__name__)
app.config.update(
    DEBUG = True,
)

app.config["SECRET_KEY"] = "\xeeIm\n\xb4K\x8e\xfc\x1el\x9cj\xf7\x1a\xe9\xceQ\x80\xc7\x1e;\x01\xf9\xe5"
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER

# database
app.config["MONGODB_DB"] = DB_NAME
connect(DB_NAME, host='mongodb://' + DB_USERNAME + ':' + DB_PASSWORD + '@' + DB_HOST_ADDRESS)
db = MongoEngine(app)

@app.route("/upload", methods=["GET", "POST"])
def upload():
    if request.method == "POST":
        file = request.files["file"]
        file_name = file.filename
        sound = Sound.get_sound(file_name)
        if not sound:
          sound = Sound()
        file_type = file_name.rsplit(".", 1)[1]
        if file and "." in file_name and file_type in ALLOWED_EXTENSIONS:
          file_name = secure_filename(file_name)
          file.save(os.path.join(app.config["UPLOAD_FOLDER"], file_name))
Example #28
0
from mongoengine import connect

from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.mongorest import MongoRest
from flask.ext.mongorest.views import ResourceView
from flask.ext.mongorest.resources import Resource
from flask.ext.mongorest import operators as ops
from flask.ext.mongorest import methods

from flask import render_template

app = Flask(__name__)
app.debug = True

app.config["MONGODB_DB"] = 'app25845098'
connect(
        'app25845098',
        username='heroku',
        password='a614e68b445d0d9d1c375740781073b4',
        host='mongodb://lowell:bander@kahana.mongohq.com:10090/app25845098',
        port=10090
)

db = MongoEngine(app)
api = MongoRest(app)

@app.route('/')
def index():
    return render_template('index.html')
Example #29
0
import csv

access_token = os.environ['CH_API_KEY']
hostname = os.environ['CH_API_HOST']

app = Flask(__name__)

app.config['SECRET_KEY'] = os.environ['SECRET']

MONGO_URL = os.environ.get("MONGOHQ_URL")

if MONGO_URL:
    credentials = re.sub(r"(.*?)//(.*?)(@hatch)", r"\2",MONGO_URL)
    username = credentials.split(":")[0]
    password = credentials.split(":")[1]
    app.config["MONGODB_DB"] = MONGO_URL.split("/")[-1]
    connect(
        MONGO_URL.split("/")[-1],
        host=MONGO_URL,
        port=1043,
        username=username,
        password=password
    )
else:
    app.config['MONGODB_DB'] = os.environ['DB_NAME']
    app.config['MONGODB_HOST'] = os.environ['DB_HOST']
    app.config['MONGODB_PORT'] = os.environ['DB_PORT']  # 27017

app.config['SECURITY_REGISTERABLE'] = True
app.config['SECURITY_SEND_REGISTER_EMAIL'] = False
app.config['SECURITY_PASSWORD_HASH'] = 'sha512_crypt'
Example #30
0
# encoding: utf-8
from flask import Flask
from flask.ext.mongoengine import MongoEngine

app = Flask(__name__)
app.config["MONGODB_DB"] = "my_blog_log"
app.config["SECRET_KEY"] = "KeepThisS3cr3t"

db = MongoEngine(app)

def register_blueprints(app):
    from luanblog.views import posts
    from luanblog.admin import admin
    app.register_blueprint(posts)
    app.register_blueprint(admin)

register_blueprints(app)


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