def setup():
    app = Flask(__name__)
    app.config["CSRF_ENABLED"] = False
    app.secret_key = "1"
    admin = Admin(app)

    return app, admin
Beispiel #2
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
Beispiel #3
0
def setup():
    app = Flask(__name__)
    app.config["SECRET_KEY"] = "1"
    app.config["CSRF_ENABLED"] = False
    admin = Admin(app)

    return app, admin
def setup():
    connect("superadmin_test")
    app = Flask(__name__)
    app.config["SECRET_KEY"] = "1"
    app.config["CSRF_ENABLED"] = False

    admin = Admin(app)

    return app, admin
Beispiel #5
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
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
Beispiel #7
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
Beispiel #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
Beispiel #9
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
Beispiel #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
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['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)

    return app
Beispiel #12
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
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
Beispiel #14
0
from flask import redirect, url_for, session
import os
import md5
import json
from collections import OrderedDict
from flask import jsonify
from sqlalchemy.ext import serializer

application = Flask(__name__)

application.config["SQLALCHEMY_DATABASE_URI"] = (
    os.environ.get("OPENSHIFT_POSTGRESQL_DB_URL")
    if os.environ.get("OPENSHIFT_POSTGRESQL_DB_URL")
    else "postgresql://localhost:5432/bio"
)
application.config["CSRF_ENABLED"] = True
application.config["SECRET_KEY"] = "rahasiabesar"

db = SQLAlchemy(application)

login_manager = LoginManager()
login_manager.init_app(application)
login_manager.login_view = "/signin"


@login_manager.user_loader
def load_user(id):
    return Users.query.get(id)


def hash_string(string):
Beispiel #15
0
# -*- coding: utf-8 -*-
import os

from flask import Flask, render_template, url_for, redirect, jsonify
from flask import request, abort, Response, flash
from flask import make_response

from werkzeug import Headers


app = Flask(__name__)
app.config["CSRF_ENABLED"] = False
app.config["SECRET_KEY"] = "asecret"


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


@app.route("/no-cache")
def no_cahce():
    response = make_response("No cache for me.", 200)
    response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
    return response


@app.route("/alert")
def alert():
    return render_template("alert.html")
Beispiel #16
0
def create_app():
    app = Flask(__name__)

    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(customattributeModule)
    # 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
Beispiel #17
0
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
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
Beispiel #19
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"))


# Definimos el decorador que devuelve el usuario en caso de que exista
@lm.user_loader
Beispiel #20
0
# from wtforms import SubmitField, StringField, BooleanField
# from wtforms import SelectField
# from wtforms.validators import Required
from acitoolkit.acitoolkitlib import Credentials
from requests import Timeout, ConnectionError

# Create application
from Forms import FeedbackForm, CredentialsForm, ResetForm
from aciSearchDb import LoginError, SearchDb

# start the flask application and tell it the static folder is called 'static'
app = Flask(__name__, static_folder="static")

# todo: need to validate the secrete key
app.config["SECRET_KEY"] = "Dnit7qz7mfcP0YuelDrF8vLFvk0snhwP"
app.config["CSRF_ENABLED"] = True
CsrfProtect(app)

bootstrap = Bootstrap(app)

# Create the ACI Search Database
sdb = SearchDb()


class APICArgs(object):
    """
    Class to hold the Arguments of the APIC
    """

    def __init__(self, ipaddr, username, secure, password):
        self.login = username
Beispiel #21
0
# -*- encoding: utf-8 -*-

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

import json

app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://train_user:bike_train@127.0.0.1/traindb"
# app.config['SQLALCHEMY_ECHO'] = 'True'
# app.config['SQLALCHEMY_RECORD_QUERIES'] = 'True'
# app.config['PROPAGATE_EXCEPTIONS'] = True
app.config["CSRF_ENABLED"] = None

db = SQLAlchemy(app)

print "models"
print db


def init_db():
    db.create_all()


class TJUser(db.Model):
    __tablename__ = "users"
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)
    passwd = db.Column(db.String(120))