Пример #1
0
def create_app():
    app = Flask(__name__, static_folder=os.path.join(PROJECT_ROOT, "public"), static_url_path="/public")

    app.config.update(os.environ)

    # TODO: read in right hand side from HT config vars
    app.config["SECRET_KEY"] = "secret"
    app.config["SECURITY_PASSWORD_HASH"] = "bcrypt"
    app.config["MONGODB_DB"] = "flask_security_test"
    app.config["MONGODB_HOST"] = "localhost"
    app.config["MONGODB_PORT"] = 27017

    app.debug = app.config["X_HT_DEBUG"] == "True"

    app.wsgi_app = SharedDataMiddleware(app.wsgi_app, {"/": os.path.join(os.path.dirname(__file__), "public")})

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

    SecuritySetup(app)

    # import & register blueprints here:
    # ===================================
    from hero_tmpl.views.security import security

    app.register_blueprint(security)

    from hero_tmpl.views.misc import misc

    app.register_blueprint(misc)

    return app
Пример #2
0
def create_app(config_name):
    app = Flask(__name__)
    app.config["MONGODB_DB"] = os.environ.get("DB_NAME", "semcomp")
    app.config["MONGODB_HOST"] = os.environ.get("DB_HOST", "localhost")
    app.config["MONGODB_PORT"] = int(os.environ.get("DB_PORT", 27017))
    app.config["MONGODB_USERNAME"] = os.environ.get("DB_USER", "")
    app.config["MONGODB_PASSWORD"] = os.environ.get("DB_PASS", "")

    db.init_app(app)

    app.jinja_env.add_extension("pyjade.ext.jinja.PyJadeExtension")

    from .main import main as main_blueprint
    from .api import api as api_blueprint

    app.register_blueprint(main_blueprint)
    app.register_blueprint(api_blueprint)

    api_rest = Api(app, prefix="/api")

    # adicionar rotas
    from .api import routes

    routes.route_all_resources(api_rest)

    return app
Пример #3
0
def create_app(config=None):
    app = Flask("tweet_wall")
    app.config["MONGODB_DB"] = os.getenv("TW_MONGODB_DB")
    app.config["MONGODB_HOST"] = os.getenv("TW_MONGODB_HOST")

    db.init_app(app)

    app.jinja_env.filters["twitter_normal_to_bigger"] = twitter_normal_to_bigger

    token = read_bearer_token_file(".oauth2_bearer_token")
    twitter = Twitter(auth=OAuth2(bearer_token=token))

    @app.route("/approved")
    @app.route("/index")
    @app.route("/")
    def approved_tweets():
        tweets = model.Tweet.objects(approved=True).order_by("-id_str").all()
        return render_template("public.html", tweets=tweets)

    @app.route("/approve", methods=["GET"])
    @requires_auth
    def approve_tweet_get():
        hash_tag = _get_hash_tag_query_param()
        tweets_twitter = twitter.search.tweets(q=hash_tag)["statuses"]

        tweets_local = model.Tweet.objects(approved=True).all()
        tweets_local_ids = [tweet.id_str for tweet in tweets_local]

        tweets_not_approved = [tweet for tweet in tweets_twitter if tweet["id_str"] not in tweets_local_ids]

        return render_template("approve_tweets.html", tweets=tweets_not_approved)

    @app.route("/approve/<string:id_str>", methods=["POST"])
    @requires_auth
    def approve_tweet_post(id_str):
        tweet = twitter.statuses.show(id=id_str)
        tweet["approved"] = True
        tweet.pop("id")
        model.Tweet.objects(id_str=tweet["id_str"]).update_one(upsert=True, **tweet)
        return redirect(url_for("approve_tweet_get"))

    @app.route("/twitter")
    def tweets():
        hash_tag = _get_hash_tag_query_param()
        tweet_search = twitter.search.tweets(q=hash_tag)["statuses"]
        return render_template("public.html", tweets=tweet_search)

    return app
Пример #4
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
Пример #5
0
def create_app(db_interface, app_name="testapp", db_name="__test-db__"):
    app = Flask(app_name)
    app.config["SERVER_NAME"] = "localhost:5000"

    if db_interface == "pymongo":
        app.config["MONGO_DBNAME"] = db_name
        mongo = PyMongo(app)
        with app.app_context():
            app.session_interface = MongoDBSessionInterface(app, mongo.db, "sessions")
    elif db_interface == "mongoengine":
        app.config["MONGODB_DB"] = db_name
        mongo = MongoEngine(app)
        app.session_interface = MongoDBSessionInterface(app, mongo.connection[app.config["MONGODB_DB"]], "sessions")

    @app.route("/set")
    def set_session():
        session["data"] = request.args["d"]
        return "data"

    @app.route("/setpermanent")
    def set_permanent_session():
        session.permanent = True
        session["data"] = request.args["d"]
        return "data"

    @app.route("/get")
    def get_session():
        return session.get("data", "")

    @app.route("/unicode/set")
    def unicode_set():
        session["foo"] = u"Alpenerstra\xdfe"
        return "done"

    @app.route("/unicode/get")
    def unicode_get():
        return session["foo"]

    return app
Пример #6
0
from flask.ext.mongoengine import MongoEngine, MongoEngineSessionInterface
from mongoengine import connect
import pdb

# Set up app with debugging
app = Flask(__name__)
if os.environ["NOTABLE_PRODUCTION"] == "0":
    app.debug = True
    app.config["MONGODB_SETTINGS"] = {"DB": "paf14"}
else:
    app.config["MONGODB_SETTINGS"] = {
        "db": "IbmCloud_3ih71bem_1vl2qqqs",
        "host": "ds035760.mongolab.com",
        "port": 35760,
    }
    app.config["MONGODB_DB"] = "IbmCloud_3ih71bem_1vl2qqqs"
    app.config["MONGODB_USERNAME"] = os.environ["MONGO_UN_NOTEABLE"]
    app.config["MONGODB_PASSWORD"] = os.environ["MONGO_PW_NOTEABLE"]
    app.config["PASSWORD"] = os.environ["MONGO_PW_NOTEABLE"]
    print "connect to mongo server"
    connect(
        "IbmCloud_3ih71bem_1vl2qqqs",
        host="mongodb://"
        + os.environ["MONGO_UN_NOTEABLE"]
        + ":"
        + os.environ["MONGO_PW_NOTEABLE"]
        + "@ds035760.mongolab.com:35760/IbmCloud_3ih71bem_1vl2qqqs",
    )

# secret key needed to use sessions
app.config["SECRET_KEY"] = os.environ["USER_AUTH_SECRET_KEY"]
Пример #7
0
import os

from flask import Flask

app = Flask(__name__)
app.config.from_object("config")

from mongoengine import connect
from flask.ext.mongoengine import MongoEngine

# Connect to the DB
app.config["MONGODB_DB"] = os.environ.get("DB_NAME") or app.config["DB_NAME"]

# For Heroku MongoHQ Add-On
if os.environ.get("MONGOHQ_URL"):
    connect(app.config["DB_NAME"], host=os.environ.get("MONGOHQ_URL"))
else:
    connect(
        app.config["DB_NAME"],
        host="mongodb://"
        + app.config["DB_USERNAME"]
        + ":"
        + app.config["DB_PASSWORD"]
        + "@"
        + app.config["DB_HOST_ADDRESS"],
    )
db = MongoEngine(app)

# login/openid
from flask.ext.login import LoginManager
from flask.ext.openid import OpenID
Пример #8
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(recorded_at=time_measured, ibi=ibi_value, hr=hr_value)
    data.save()
    time.sleep(1)
Пример #9
0
    mail_url,
    mail_SSL,
    mail_port,
    mail_TLS,
    mail_user,
    mail_pass,
)


app = Flask(__name__)

app.config["DEBUG"] = False
app.config["SECRET_KEY"] = secret_key

# MongoDB Config
app.config["MONGODB_DB"] = mongo_db
app.config["MONGODB_HOST"] = mongo_host
app.config["MONGODB_PORT"] = mongo_port

# Security Features
app.config["SECURITY_REGISTERABLE"] = user_enable_registration
app.config["SECURITY_TRACKABLE"] = user_enable_tracking
app.config["SECURITY_EMAIL_SENDER"] = user_from_email
app.config["SECURITY_PASSWORD_HASH"] = pwhash
app.config["SECURITY_PASSWORD_SALT"] = salt
app.config["SECURITY_CONFIRMABLE"] = True
app.config["SECURITY_EMAIL_SUBJECT_REGISTER"] = user_register_email_subject

# Email
app.config["MAIL_SERVER"] = mail_url
app.config["DEBUG"] = False
Пример #10
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()
Пример #11
0
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):
Пример #12
0
# overriding default jinja template tags, to avoid conflicts with angularjs
app.jinja_env.variable_start_string = "{["
app.jinja_env.variable_end_string = "]}"

app.config["SECRET_KEY"] = os.environ["SECRET_KEY"]

# allow debugging heroku code
if os.environ.get("DEBUG"):
    app.config["DEBUG"] = True

# create the db connection, username and password only set if it exists
if os.environ.get("ENV", "dev") == "pro":
    app.config["MONGODB_HOST"] = os.environ.get("MONGOLAB_URI")
    app.config["MONGODB_DB"] = "final"
else:
    app.config["MONGODB_USERNAME"] = os.environ.get("MONGO_DB_USERNAME")
    app.config["MONGODB_PASSWORD"] = os.environ.get("MONGO_DB_PASSWORD")
    app.config["MONGODB_DB"] = "test"

db = MongoEngine(app)

app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER

# set up login manager
login_manager = LoginManager()
login_manager.init_app(app)

# set url to redirect to for login
login_manager.login_view = "signin"

from User import User
Пример #13
0
# -*- encoding: utf-8 -*-
from flask import Flask, render_template, flash, request
from forms import ClienteForm
from flask.ext.mongoengine import MongoEngine
from mongoengine import NotUniqueError

app = Flask(__name__)

app.debug = True
app.config["MONGODB_DB"] = "cadcli"
app.config["SECRET_KEY"] = "FeDs03hisS3@%#34"

db = MongoEngine(app)

#=================================================================== MODELS

class Endereco(db.Document):
	cidade = db.StringField()
	estado = db.StringField()
	rua = db.StringField()

class Cliente(db.Document):
	nome = db.StringField()
	endereco = db.ReferenceField(Endereco, reverse_delete_rule=db.CASCADE)
	telefone_res = db.StringField()
	telefone_cel = db.StringField()
	telefone_com = db.StringField()
	email = db.EmailField(unique=True)
	data_nascimento = db.DateTimeField()
	ativo = db.BooleanField()
Пример #14
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()
Пример #15
0
from flask import Flask, url_for, send_from_directory, render_template
from flask.ext.mongoengine import MongoEngine, ValidationError
from flask.ext.mongoengine.wtf import model_form
from flask.ext.security import Security, MongoEngineUserDatastore, UserMixin, RoleMixin, login_required
from flask_mail import Mail
from flask_security.core import current_user

# Create app
app = Flask(__name__)
app.config["DEBUG"] = True
app.config["SECRET_KEY"] = "super-secret"
app.config["SECURITY_REGISTERABLE"] = True
# MongoDB Config
app.config["MONGODB_DB"] = "mydatabase"
app.config["MONGODB_HOST"] = "localhost"
app.config["MONGODB_PORT"] = 27017

app.config["DEFAULT_MAIL_SENDER"] = "hello@refrew.com"
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = "nirav.shah83@gmail.com"
app.config["MAIL_PASSWORD"] = "Alpha6383"
app.url_map.strict_slashes = False

mail = Mail(app)


@app.route("/")
def home():
    return render_template("index.html", user=current_user)
Пример #16
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:
Пример #17
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)
Пример #18
0
def create_app(object_name, env="prod"):
    """
    A flask application factory, as explained here:
    http://flask.pocoo.org/docs/patterns/appfactories/

    Inputs:  ::\n
        object_name: the python path of the config object,
                     e.g. appname.settings.ProdConfig

        env: The name of the current environment, e.g. prod or dev
    """

    app = Flask(__name__)

    app.config.from_object(object_name)
    app.config["ENV"] = env

    # Init the cache
    cache.init_app(app)

    # Init debug toolbar
    debug_toolbar.init_app(app)

    # Init Mongo engine
    # mongoengine.connect(config.MONGODB_FRONTEND_DB_NAME, host=config.MONGODB_HOST, port=config.MONGODB_PORT)
    app.config["MONGODB_DB"] = config.MONGODB_FRONTEND_DB_NAME
    app.config["MONGODB_HOST"] = config.MONGODB_HOST
    app.config["MONGODB_PORT"] = config.MONGODB_PORT
    db.init_app(app)

    # Init login_manager
    login_manager.init_app(app)
    login_manager.login_view = "main.login"
    login_manager.refresh_view = "main.login"
    # Init current to track current project/experiment
    current.init_app(app)

    # Import and register the different asset bundles
    assets_env.init_app(app)
    assets_loader = PythonAssetsLoader(assets)
    for name, bundle in assets_loader.load_bundles().iteritems():
        assets_env.register(name, bundle)

    # register all the  blueprints
    from controllers import (
        main,
        error,
        dashboard,
        new_experiment,
        new_project,
        account_settings,
        project,
        experiment,
        targets,
        setup,
    )

    app.register_blueprint(main)
    app.register_blueprint(error, url_prefix="/error")
    app.register_blueprint(dashboard, url_prefix="/dashboard")
    app.register_blueprint(new_experiment, url_prefix="/new_experiment")
    app.register_blueprint(new_project, url_prefix="/new_project")
    app.register_blueprint(account_settings, url_prefix="/account_settings")
    app.register_blueprint(project, url_prefix="/project")
    app.register_blueprint(experiment, url_prefix="/experiment")
    app.register_blueprint(targets, url_prefix="/targets")
    app.register_blueprint(setup, url_prefix="/setup")

    return app
Пример #19
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"},
Пример #20
0
from flask import Flask
from mongoengine import connect

app = Flask(__name__)
app.debug = True

app.config["MONGODB_DB"] = "app14198794"
connect(
    "app14198794",
    username="heroku",
    password="a614e68b445d0d9d1c375740781073b4",
    host="mongodb://heroku:a614e68b445d0d9d1c375740781073b4@alex.mongohq.com:10095/app14198794",
    port=10095,
)
Пример #21
0
import local_settings
from flaskext.mongoengine import MongoEngine


# 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()
Пример #22
0
from flask import Flask
from flask_mongoengine import MongoEngine
from mongoengine import StringField, IntField

from flask_potion import Api, ModelResource, fields
from flask.ext.potion.contrib.mongoengine.manager import MongoEngineManager

app = Flask(__name__)
app.debug = True
app.config["MONGODB_DB"] = "potion-example"

me = MongoEngine(app)


class Book(me.Document):
    title = StringField(null=False, unique=True)
    year_published = IntField(null=True)


class BookResource(ModelResource):
    class Meta:
        name = "book"
        model = Book

    class Schema:
        year_published = fields.Integer(minimum=1400)


api = Api(app, default_manager=MongoEngineManager)
api.add_resource(BookResource)
Пример #23
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()
Пример #24
0
import urlparse
import errno
import time
import datetime
import gzip
import pytz
from StringIO import StringIO
from flask import url_for, Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.script import Manager, Command, Option
import jinja2


app = Flask(__name__)

app.config["MONGODB_DB"] = "sitemap"

db = MongoEngine(app)

manager = Manager(app)


class User(db.Document):
    uid = db.SequenceField()
    username = db.StringField()
    last_accessed = db.DateTimeField(default=datetime.datetime.utcnow)

    # Added for direct access of 'artwork_aid's and 'product_detail_pid's
    # via a file
    artwork_meta_aid_file = db.StringField()
    product_meta_pid_file = db.StringField()
Пример #25
0
from flask_mongoengine import MongoEngine
from flask_debugtoolbar import DebugToolbarExtension
from flask_login import LoginManager

from utils import user_unauthorized_callback, load_user

from urls import add_urls

# Determining the project root.
PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))

# Creating the Flask app object
app = Flask(__name__, static_folder=os.path.join(PROJECT_ROOT, "static"), static_url_path="/static")

# Flask config settings
app.config["MONGODB_DB"] = "ncdc"
app.config["MONGODB_SETTINGS"] = {"USERNAME": "<name>", "PASSWORD": "<password>", "DB": "<db>"}
app.config["SECRET_KEY"] = "my_super_secret_key"
app.debug = False

# Setting up the login manager for Flask-Login
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.unauthorized_handler(user_unauthorized_callback)
login_manager.user_loader(load_user)

# Setting up the connection to the MongoDB backend.
db = MongoEngine(app)

# Add all of the url rules for the application.  Any url answered by the application must be
# mapped to a view function here.
Пример #26
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()
Пример #27
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")
Пример #28
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()
Пример #29
0
# Mongo Lab Database connection
# DB_NAME = 'jrflask'
# DB_USERNAME = 'jrflaskadmin'
# DB_PASSWORD = 'jrflask12345'
# DB_HOST_ADDRESS = 'ds031278.mongolab.com:31278/jrflask'
# app.config["MONGODB_DB"] = DB_NAME
# connect(DB_NAME, host='mongodb://' + DB_USERNAME + ':' + DB_PASSWORD + '@' + DB_HOST_ADDRESS)

# MongoHQ Database connection
DB_NAME = "app15407585"
DB_USERNAME = "heroku"
DB_PASSWORD = "6cefeffb1806c2444c074e4b680ff76f"
DB_HOST_ADDRESS = "ethan.mongohq.com"
DB_PORT = 10031
app.config["MONGODB_DB"] = DB_NAME
connect(
    DB_NAME,
    username=DB_USERNAME,
    password=DB_PASSWORD,
    host="mongodb://" + DB_USERNAME + ":" + DB_PASSWORD + "@" + DB_HOST_ADDRESS + ":" + str(DB_PORT) + "/" + DB_NAME,
    port=DB_PORT,
)

db = MongoEngine(app)


# ----------------------------------------
# launch
# ----------------------------------------
Пример #30
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()