Example #1
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('config')

    # Create modules
    app.register_blueprint(newsModule)
    app.register_blueprint(commentsModule)
    app.register_blueprint(weibosModule)
    app.register_blueprint(clusterModule)
    app.register_blueprint(packageModule)
    app.register_blueprint(packageWeiboModule)

    # Enable the toolbar?
    app.config['DEBUG_TB_ENABLED'] = app.debug
    # Should intercept redirects?
    app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
    # Enable the profiler on all requests, default to false
    app.config['DEBUG_TB_PROFILER_ENABLED'] = True
    # Enable the template editor, default to false
    app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True
    # debug toolbar
    # toolbar = DebugToolbarExtension(app)

    # the debug toolbar is only enabled in debug mode
    app.config['DEBUG'] = True

    app.config['ADMINS'] = frozenset(['youremail@yourdomain.com'])
    app.config['SECRET_KEY'] = 'SecretKeyForSessionSigning'
    app.config['THREADS_PER_PAGE'] = 8

    app.config['CSRF_ENABLED'] = True
    app.config['CSRF_SESSION_KEY'] = 'somethingimpossibletoguess'

    return app
Example #2
0
def setup():
    app = Flask(__name__)
    app.config['CSRF_ENABLED'] = False
    app.secret_key = '1'
    admin = Admin(app)

    return app, admin
Example #3
0
def setup():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False
    admin = Admin(app)

    return app, admin
Example #4
0
def create_app():
    app = Flask(__name__)

    register_blueprints(app)
    register_extensions(app)
    register_jinja_funcs(app)

    # Create modules
    # the debug toolbar is only enabled in debug mode
    app.config['DEBUG'] = True

    app.config['ADMINS'] = frozenset(['youremail@yourdomain.com'])
    app.config['SECRET_KEY'] = 'SecretKeyForSessionSigning'
    
    app.config['DATABASE_CONNECT_OPTIONS'] = {}

    app.config['THREADS_PER_PAGE'] = 8

    app.config['CSRF_ENABLED'] = True
    app.config['CSRF_SESSION_KEY'] = 'somethingimpossibletoguess'

    # Enable the toolbar?
    app.config['DEBUG_TB_ENABLED'] = app.debug
    # Should intercept redirects?
    app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
    # Enable the profiler on all requests, default to false
    app.config['DEBUG_TB_PROFILER_ENABLED'] = True
    # Enable the template editor, default to false
    app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True
    
    # debug toolbar
    # toolbar = DebugToolbarExtension(app)
    
    return app
def setup():
    connect('superadmin_test')
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False

    admin = Admin(app)

    return app, admin
Example #6
0
def setup():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'

    db = peewee.SqliteDatabase(':memory:')
    admin = Admin(app)

    return app, db, admin
Example #7
0
def setup():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'

    db = SQLAlchemy(app)
    admin = Admin(app)

    return app, db, admin
Example #8
0
def setup():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/flask_admin_test'
    app.config['SQLALCHEMY_ECHO'] = True

    db = SQLAlchemy(app)
    admin = Admin(app)

    return app, db, admin
Example #9
0
def setup():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = '1'
    app.config['CSRF_ENABLED'] = False

    conn = pymongo.Connection()
    db = conn.tests

    admin = Admin(app)

    return app, db, admin
Example #10
0
def make_app(env="dev"):
    
    DEBUG = True #= env == "dev"
    
    url_root = {
        "dev": "/",
        "prod": "/dist/",
        "test": "/dist/"
    }[env]
    
    app_home = os.path.dirname(__file__)
    
    cfg = {
        "dev": dict(
            static_url_path="",
            template_folder="..",
            static_folder=opa(opj(app_home, ".."))
            ),
        "prod": dict(
            static_url_path="/dist",
            template_folder="..",
            static_folder=opa(opj(app_home, "..", "dist"))
            ),
        "test": dict(
            static_url_path="/dist",
            template_folder="../dist",
            static_folder=opa(opj(app_home, "..", "dist"))
            )
    }[env]
    
    app = Flask(__name__, **cfg)
    app.config['CSRF_ENABLED'] = DEBUG
    app.config['SECRET_KEY'] = "totally-insecure"
    app.config['DEBUG'] = DEBUG

    @app.route(url_root)
    def home():
        
        kwargs = {}
        if env != "test":
            kwargs.update(assets())
        
        return render_template("index.html", env=env, **kwargs)

    @app.route(url_root + "frame/")
    def frame():
        kwargs = {}
        if env != "test":
            kwargs.update(assets("../frame/"))
            
        return render_template("frame/index.html", env=env, **kwargs)
        
    return app
Example #11
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 #12
0
def create_app():
    app = Flask(__name__)

    app.config['SECRET_KEY'] = 'password' 
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.config['CSRF_ENABLED'] = True
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ['DATABASE_URL'] or 'postgresql://localhost/findtable'

    db.init_app(app)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)
    print(os.environ['DATABASE_URL'])

    return app
Example #13
0
#
# Инициализация приложения
#

# Основной объект приложения Flask
from flask import Flask

# Создать экземпляр класса, который будет WSGI-приложением,
# аргумент помогает определить роль (место вызова) - либо это
# модуль, либо standalone-приложение
app = Flask(__name__)

# Отключение CSRF для WTF-Forms
app.config['CSRF_ENABLED'] = True
app.config['SECRET_KEY'] = 'just qwerty'

# Импорт обработчиков запросов клиентов
from app import views
Example #14
0
import os
from flask import Flask,redirect,url_for
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask_openid import OpenID
from config import basedir
from datetime import timedelta
import config
from config import adminusers

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']= config.DB_URI
app.config['SECRET_KEY']=config.SECRET_KEY
app.config['CSRF_ENABLED']=config.CSRF_ENABLED
app.config['OPENID_PROVIDERS']=config.OPENID_PROVIDERS
db = SQLAlchemy(app)

#Creamos el Login Manager
lm = LoginManager()
lm.setup_app(app)
lm.refresh_view = 'login'
app.config['REMEMBER_COOKIE_DURATION']=timedelta(minutes=2)
lm.needs_refresh_message = (
    u"Para proteger el acceso por favor inicia sesion de nuevo"
    )
lm.session_protection = "strong"

#Creamos el Openid
oid = OpenID(app, os.path.join(basedir, 'tmp'))

def create_app():
    app = Flask(__name__)
    #下面这一句新加的
    app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///flask-admin.db'
    register_blueprints(app)
    register_extensions(app)
    register_jinja_funcs(app)

    # Create modules

    # the debug toolbar is only enabled in debug mode
    app.config['DEBUG'] = True

    app.config['ADMINS'] = frozenset(['youremail@yourdomain.com'])
    app.config['SECRET_KEY'] = 'SecretKeyForSessionSigning'
    
    '''
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+mysqldb://%s:@%s/%s?charset=utf8' % (MYSQL_USER, MYSQL_HOST, MYSQL_DB)
    app.config['SQLALCHEMY_ECHO'] = False
    '''
    app.config['DATABASE_CONNECT_OPTIONS'] = {}

    app.config['THREADS_PER_PAGE'] = 8

    app.config['CSRF_ENABLED'] = True
    app.config['CSRF_SESSION_KEY'] = 'somethingimpossibletoguess'

    # Enable the toolbar?
    app.config['DEBUG_TB_ENABLED'] = app.debug
    # Should intercept redirects?
    app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
    # Enable the profiler on all requests, default to false
    app.config['DEBUG_TB_PROFILER_ENABLED'] = True
    # Enable the template editor, default to false
    app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True
    
    # debug toolbar
    # toolbar = DebugToolbarExtension(app)
#新加的app.config到return之前
    app.config['MONGO_HOST'] = '219.224.134.211'    
    app.config['MONGO_PORT'] = 27017    
    app.config['MONGO_DBNAME'] = 'mrq'   
     # init database
    db.init_app(app)
    with app.test_request_context():
        db.create_all()

    # init security
    security.init_app(app, datastore=user_datastore)

    # init admin
    admin.init_app(app)
    #admin.add_view(AdminAccessView(User, db.session))
    #admin.add_view(AdminAccessView(Role, db.session))
    #admin.add_view(sqla.ModelView(User, db.session))
    #admin.add_view(sqla.ModelView(Role, db.session))
    #admin.add_view(Roleadmin(db.session))

    # init mongo
    mongo.init_app(app)         

    return app
from flask import Flask
from app.utils.config_helper import app_wtf, general

app = Flask(__name__)

app.config['CSRF_ENABLED'] = app_wtf['csrf_enabled']
app.config['SECRET_KEY'] = app_wtf['secret_key']


from app.views import home, login, master, metaloggers, chunkservers, clients, data, trash
Example #17
0
#import Boto - for Photos
import boto

from werkzeug import secure_filename

# Python Image Library
import StringIO

# conn = boto.connect_s3()

# for json needs
import json
from flask import jsonify

app = Flask(__name__)   # create our flask app
app.config['CSRF_ENABLED'] = False #Cross Site Request Forgery - our forms are good....no security needed...Turning it on causes error because there's not a module.
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16 megabyte file upload

# --------- Database Connection ---------
# MongoDB connection to MongoLab's database
connect('mydatabase', host=os.environ.get('MONGOLAB_URI'))
app.logger.debug("Connecting to MongoLabs")

ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])


#----------	S3 Boto Connections -----------
from boto.s3.connection import S3Connection
from boto.s3.key import Key
conn = S3Connection(os.environ.get('AWS_ACCESS_KEY_ID'),os.environ.get('AWS_SECRET_ACCESS_KEY'))
app.logger.debug("Connecting to AWS")
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

application = Flask(__name__)
application.config.from_pyfile('config.py')
application.config['CSRF_ENABLED'] = True,
application.config['SECRET_KEY'] = 'THIS IS THE SECRET FOR THE GATEWAY'
db = SQLAlchemy(application)
def create_app():
    app = Flask(__name__)
    app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///flask-admin.db'

    register_blueprints(app)
    register_extensions(app)
    register_jinja_funcs(app)

    # Create modules
    app.register_blueprint(indexModule)
    app.register_blueprint(manageModule)
    app.register_blueprint(attributeModule)
    app.register_blueprint(recommentationModule)
    app.register_blueprint(overviewModule)
    app.register_blueprint(influenceModule)
    app.register_blueprint(loginModule)
    app.register_blueprint(groupModule)
    app.register_blueprint(detectModule)
    app.register_blueprint(tagModule)
    app.register_blueprint(ucenterModule)
 #   app.register_blueprint(weiboModule)
    app.register_blueprint(sensingModule)
    app.register_blueprint(sentimentModule)
    app.register_blueprint(networkModule)
    app.register_blueprint(userrankModule)
    # the debug toolbar is only enabled in debug mode
    app.config['DEBUG'] = True

    app.config['ADMINS'] = frozenset(['youremail@yourdomain.com'])
    app.config['SECRET_KEY'] = 'SecretKeyForSessionSigning'
    app.config["WTF_CSRF_ENABLED"] = False #2016-04-13

    
    '''
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+mysqldb://%s:@%s/%s?charset=utf8' % (MYSQL_USER, MYSQL_HOST, MYSQL_DB)
    app.config['SQLALCHEMY_ECHO'] = False
    '''
    app.config['DATABASE_CONNECT_OPTIONS'] = {}

    app.config['THREADS_PER_PAGE'] = 8

    app.config['CSRF_ENABLED'] = True
    app.config['CSRF_SESSION_KEY'] = 'somethingimpossibletoguess'

    # Enable the toolbar?
    app.config['DEBUG_TB_ENABLED'] = app.debug
    # Should intercept redirects?
    app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
    # Enable the profiler on all requests, default to false
    app.config['DEBUG_TB_PROFILER_ENABLED'] = True
    # Enable the template editor, default to false
    app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True

    app.config['MONGO_HOST'] = '10.128.55.83'    
    app.config['MONGO_PORT'] = 27017    
    app.config['MONGO_DBNAME'] = 'mrq'    

    # debug toolbar
    # toolbar = DebugToolbarExtension(app)

    # init database
    db.init_app(app)
    with app.test_request_context():
        db.create_all()

    # init security
    security.init_app(app, datastore=user_datastore)

    # init admin
    admin.init_app(app)
    admin.add_view(AdminAccessView(User, db.session))
    admin.add_view(AdminAccessView(Role, db.session))
    #admin.add_view(sqla.ModelView(User, db.session))
    #admin.add_view(sqla.ModelView(Role, db.session))
    #admin.add_view(Roleadmin(db.session))

    # init mongo
    mongo.init_app(app)    

    '''
    app.config['MONGO_HOST'] = MONGODB_HOST
    app.config['MONGO_PORT'] = MONGODB_PORT

    app.config['MONGODB_SETTINGS'] = {
        'db': MASTER_TIMELINE_54API_WEIBO_DB,
        'host': MONGODB_HOST,
        'port': MONGODB_PORT
    }

    # Create mysql database
    db.init_app(app)
    with app.test_request_context():
        db.create_all()

    # Create mongo_engine
    mongo_engine.init_app(app)

    admin.init_app(app)
    """
    # Create mysql database admin, visit via url: http://HOST:PORT/admin/
    for m in model.__all__:
        m = getattr(model, m)
        n = m._name()
        admin.add_view(SQLModelView(m, db.session, name=n))

    for m in mongodb_model.__all__:
        admin.add_view(MongoDBView(m))
    """

    # init mongo
    mongo.init_app(app)
    '''
    return app
Example #20
0
def create_app():
    app = Flask(__name__)

    # Create modules
    app.register_blueprint(rootModule)
    app.register_blueprint(moodlensModule)
    app.register_blueprint(opinionModule)
    app.register_blueprint(propagateModule)
    app.register_blueprint(indexModule)
    app.register_blueprint(evolutionModule)
    app.register_blueprint(identifyModule)
    app.register_blueprint(quota_systemModule)
    app.register_blueprint(dataoutModule)

    # the debug toolbar is only enabled in debug mode
    app.config['DEBUG'] = True

    app.config['ADMINS'] = frozenset(['youremail@yourdomain.com'])
    app.config['SECRET_KEY'] = 'SecretKeyForSessionSigning'

    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+mysqldb://%s:@%s/%s?charset=utf8' % (MYSQL_USER, MYSQL_HOST, MYSQL_DB)
    app.config['SQLALCHEMY_ECHO'] = False
    app.config['DATABASE_CONNECT_OPTIONS'] = {}

    app.config['THREADS_PER_PAGE'] = 8

    app.config['CSRF_ENABLED'] = True
    app.config['CSRF_SESSION_KEY'] = 'somethingimpossibletoguess'

    # Enable the toolbar?
    app.config['DEBUG_TB_ENABLED'] = app.debug
    # Should intercept redirects?
    app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True
    # Enable the profiler on all requests, default to false
    app.config['DEBUG_TB_PROFILER_ENABLED'] = True
    # Enable the template editor, default to false
    app.config['DEBUG_TB_TEMPLATE_EDITOR_ENABLED'] = True
    # debug toolbar
    # toolbar = DebugToolbarExtension(app)

    app.config['MONGO_HOST'] = MONGODB_HOST
    app.config['MONGO_PORT'] = MONGODB_PORT

    app.config['MONGODB_SETTINGS'] = {
        'db': MASTER_TIMELINE_54API_WEIBO_DB,
        'host': MONGODB_HOST,
        'port': MONGODB_PORT
    }

    # Create mysql database
    db.init_app(app)
    with app.test_request_context():
        db.create_all()

    # Create mongo_engine
    mongo_engine.init_app(app)

    admin.init_app(app)
    """
    # Create mysql database admin, visit via url: http://HOST:PORT/admin/
    for m in model.__all__:
        m = getattr(model, m)
        n = m._name()
        admin.add_view(SQLModelView(m, db.session, name=n))

    for m in mongodb_model.__all__:
        admin.add_view(MongoDBView(m))
    """

    # init mongo
    mongo.init_app(app)

    return app
Example #21
0
# -*- coding: utf-8 -*-
import os, datetime
import re
import requests
from unidecode import unidecode

from flask import Flask, request, render_template, redirect, abort, jsonify

# import all of mongoengine
from mongoengine import *

# import data models
import models

app = Flask(__name__)   # create our flask app
app.config['CSRF_ENABLED'] = False

# --------- Database Connection ---------
# MongoDB connection to MongoLab's database
connect('mydata', host=os.environ.get('MONGOLAB_URI'))
app.logger.debug("Connecting to MongoLabs")

# hardcoded categories for the checkboxes on the form
# --------- Routes ----------

# this is our main page
@app.route("/", methods=['GET','POST'])
def index():

	# get Idea form from models.py
	user_form = models.UserForm(request.form)
Example #22
0
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.login import LoginManager
from flask.ext.bootstrap import Bootstrap

import os



#create flask 
yoke = Flask(__name__)
yoke.config['DEBUG'] = True
yoke.config['SECRET_KEY'] = 'default'
yoke.config['CSRF_ENABLED'] = True
yoke.config['CSRF_SESSION_KEY'] = 'csrf_secret'

#bootstrap init
bootstrap = Bootstrap()
bootstrap.init_app(yoke)

#init database with yoke
db = SQLAlchemy()
db.init_app(yoke)
db.app = yoke
yoke.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(os.getcwd(), 'data.sqlite') 
yoke.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
yoke.config['SQLALCHEMY_RECORD_QUERIES'] = True


#init login_manager with yoke
login_manager = LoginManager()