Example #1
1
def create_app():
    options = {"port": 0, "unitTesting": False}
    WebConfig.config(options)

    b = Borg()
    app = Flask(__name__)
    app.config["DEBUG"] = True
    app.config["SECRET_KEY"] = b.secretKey
    app.config["SECURITY_PASSWORD_HASH"] = b.passwordHash
    app.config["SECURITY_PASSWORD_SALT"] = b.passwordSalt
    app.config["SQLALCHEMY_DATABASE_URI"] = (
        "mysql://" + b.auth_dbUser + ":" + b.auth_dbPasswd + "@" + b.auth_dbHost + "/" + b.auth_dbName
    )
    b.logger.setLevel(b.logLevel)
    b.logger.debug("Error handlers: {0}".format(app.error_handler_spec))
    app.secret_key = os.urandom(24)
    logger = logging.getLogger("werkzeug")
    logger.setLevel(b.logLevel)
    enable_debug = b.logLevel = logging.DEBUG

    cors = CORS(app)
    db.init_app(app)
    user_datastore = SQLAlchemyUserDatastore(db, User, Role)
    security = Security(app, user_datastore)

    from main import main as main_blueprint

    app.register_blueprint(main_blueprint)

    with app.app_context():
        db.create_all()

    return app
Example #2
0
    def create_app(self):
        """Create the app."""
        from flask_iiif import IIIF
        from flask_restful import Api
        from flask_iiif.cache.simple import ImageSimpleCache

        app = Flask(__name__)
        app.config["DEBUG"] = True
        app.config["TESTING"] = True
        app.config["SERVER_NAME"] = "shield.worker.node.1"
        app.config["SITE_URL"] = "http://shield.worker.node.1"
        app.config["IIIF_CACHE_HANDLER"] = ImageSimpleCache()
        app.logger.disabled = True

        api = Api(app=app)

        iiif = IIIF(app=app)

        iiif.uuid_to_image_opener_handler(self.create_image)

        def api_decorator_test(*args, **kwargs):
            if "decorator" in kwargs.get("uuid"):
                abort(403)

        iiif.api_decorator_handler(api_decorator_test)

        iiif.init_restful(api)
        return app
Example #3
0
def create_app():
    global app
    global db
    global login_manager

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

    # SQLAlchemy
    db = SQLAlchemy(app)

    # Login
    login_manager = LoginManager(app)
    login_manager.login_view = "users.login"

    # Assets
    assets = Environment(app)
    less = Bundle("less/*.less", filters="less", output="css/gen/style.css", depends="less/*.less")
    assets.register("less_all", less)

    # Debug
    app.config["DEBUG"] = len(argv) == 2 and argv[1] == "debug"

    @login_manager.user_loader
    def load_user(userid):
        from models import User

        return User.query.get(userid)

    register_blueprints(app)
    return app, db
Example #4
0
def create_app():
    global app
    global db
    global login_manager

    # Flask
    app = Flask(__name__, static_folder="static/dist/", static_url_path="/static")
    app.config.from_object("config.flask_config")

    # SQLAlchemy
    db = SQLAlchemy(app)

    # Login
    login_manager = LoginManager(app)
    login_manager.login_view = "users.login"

    # Debug
    app.config["DEBUG"] = len(argv) == 2 and argv[1] == "debug"

    @login_manager.user_loader
    def load_user(userid):
        from models import User

        return User.query.get(userid)

    from app.models import AnonymousUser

    login_manager.anonymous_user = AnonymousUser

    register_blueprints(app)
    return app, db
Example #5
0
    def setUp(self):
        app = Flask(__name__)
        app.config["TESTING"] = True
        app.config["DEBUG"] = True
        app.config["TRAP_HTTP_EXCEPTIONS"] = True

        secret_key = "really big secret"
        token_manager = TokenManager(secret_key)

        token_auth = TokenAuth(secret_key)

        @app.route("/token")
        def get_token():
            user = "test_user"
            token = token_manager.generate(user).decode("utf-8")
            doc = {"token": token}
            return jsonify(doc)

        @app.route("/")
        def root():
            return jsonify({"message": "OK"})

        @app.route("/token_required")
        @token_auth.token_required
        def token_required():
            response = jsonify({"message": "OK"})
            response.status_code = 200
            return response

        self.app = app
        self.client = app.test_client()
        self.secret_key = secret_key
        self.token_manager = token_manager

        return self.app
Example #6
0
    def setUp(self):
        """Creates the Flask application and the APIManager."""
        # create the Flask application
        app = Flask(__name__)
        app.config["DEBUG"] = True
        app.config["TESTING"] = True
        app.config["SECRET_KEY"] = "testing..."
        del app.logger.handlers[0]
        # sqlalchemy flask
        self.base = declarative_base()
        self.engine = create_engine("sqlite://")
        self.session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=self.engine))
        self.app = app
        self._ctx = self.app.test_request_context()
        self._ctx.push()
        self.client = self.app.test_client()

        # Add an error handler that returns straight LeverException
        # recommendations
        @self.app.errorhandler(LeverException)
        def handler(exc):
            tb = exc.extra.pop("tb", None)
            self.app.logger.debug(
                "Lever Exception Thrown!\n" "Extra: {0}\nEnd User: {1}".format(exc.extra, exc.end_user), exc_info=True
            )
            if tb:
                self.app.logger.debug("Traceback from lever exception:" "\n{0}".format(tb.replace("\\n", "\n")))
            return jsonify(**exc.end_user), exc.code

        return app
Example #7
0
    def test_will_prettyprint_json_in_debug_mode(self):
        app = Flask(__name__)
        app.config["DEBUG"] = True
        api = flask_restful.Api(app)

        class Foo1(flask_restful.Resource):
            def get(self):
                return {"foo": "bar", "baz": "asdf"}

        api.add_resource(Foo1, "/foo", endpoint="bar")

        with app.test_client() as client:
            foo = client.get("/foo")

            # Python's dictionaries have random order (as of "new" Pythons,
            # anyway), so we can't verify the actual output here.  We just
            # assert that they're properly prettyprinted.
            lines = foo.data.splitlines()
            lines = [line.decode() for line in lines]
            self.assertEquals("{", lines[0])
            self.assertTrue(lines[1].startswith("    "))
            self.assertTrue(lines[2].startswith("    "))
            self.assertEquals("}", lines[3])

            # Assert our trailing newline.
            self.assertTrue(foo.data.endswith(b"\n"))
Example #8
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 #9
0
    def create_app():

        global db, bootstrap, mail, login_manager, moment, pagedown
        app = Flask(__name__)

        from main import main as main_blueprint
        from auth import auth as auth_blueprint
        from admin import admin as admin_blueprint

        app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://flask:gf37888676@172.17.0.25/flask"
        app.config["SQLAlCHEMY_COMMIT_ON_TEARDOWN"] = True
        app.config["FLASK_ADMIN"] = "iamawar3player@163.com"
        app.config["FLASK_MAIL_SUBJECT_PREFIX"] = "[Flasky]"
        app.config["FLASK_MAIL_SENDER"] = "Flasky Admin <iamawar3player@163.com>"
        app.config["MAIL_SERVER"] = "smtp.163.com"
        app.config["MAIL_PORT"] = 25
        app.config["MAIL_USE_TLS"] = False
        app.config["MAIL_USERNAME"] = "iamawar3player@163.com"
        app.config["MAIL_PASSWORD"] = "fan86797121"
        app.config["DEBUG"] = True
        app.config["FLASKY_POSTS_PER_PAGE"] = 10
        app.config["SECRET_KEY"] = "gf37888676"
        app.register_blueprint(main_blueprint)
        app.register_blueprint(auth_blueprint, url_prefix="/auth")
        app.register_blueprint(admin_blueprint, url_prefix="/admin")

        db = db.init_app(app)
        mail = mail.init_app(app)
        bootstrap = bootstrap.init_app(app)
        login_manager = login_manager.init_app(app)
        moment = moment.init_app(app)
        pagedown = pagedown.init_app(app)

        return app
def create_app(settings=None):
    """
    Creates a flask application.

    @param settings: Settings override object.
    @return: The flask application.
    """
    app = Flask(__name__)

    if settings:
        app.config.from_object(settings)
    else:
        args = _generate_args()
        profile = args.pop("profile")
        app.config["DEBUG"] = args.pop("debug")
        config_file = _load_config_file()
        database_uri = _load_database()
        _config_from_config_profile(config_file, profile, app)
        app.config["SQLALCHEMY_DATABASE_URI"] = database_uri

    DB.init_app(app)

    default_controller = __import__("ec2stack.controllers." + "default", None, None, "DEFAULT")
    default_controller = getattr(default_controller, "DEFAULT")
    app.register_blueprint(default_controller)

    return app
Example #11
0
def create():
    """Create application.
    """

    # Create application
    app = Flask("service", static_folder=None)
    app.config["DEBUG"] = True

    # CORS support
    CORS(app)

    # Session
    sess = Session()
    app.config["SESSION_TYPE"] = "filesystem"
    app.config["SECRET_KEY"] = "openspending rocks"
    sess.init_app(app)

    # Register blueprints
    logger.info("Creating Datastore Blueprint")
    app.register_blueprint(datastore.create(), url_prefix="/datastore/")
    logger.info("Creating Package Blueprint")
    app.register_blueprint(package.create(), url_prefix="/package/")
    logger.info("Creating Authentication Blueprint")
    app.register_blueprint(user.oauth_create(), url_prefix="/oauth/")
    logger.info("Creating Users Blueprint")
    app.register_blueprint(user.create(), url_prefix="/user/")
    logger.info("Creating Search Blueprint")
    app.register_blueprint(search.create(), url_prefix="/search/")

    # Return application
    return app
Example #12
0
def create_app(config=None):
    app = Flask(__name__)

    app.config["SECRET_KEY"] = "129iv3n91283nv9812n3v89q2nnv9iaszv978n98qwe7z897d"
    app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://postgres@localhost/mooddiaryDb"
    # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/mooddiary.db'

    app.config["DEBUG"] = True
    app.config["LESS_BIN"] = os.path.realpath(os.path.join(os.path.dirname(__file__), "../node_modules/less/bin/lessc"))

    app.config["JWT_EXPIRATION_DELTA"] = timedelta(days=28)
    app.config["JWT_ALGORITHM"] = "HS512"

    app.config["RECAPTCHA_SECRET_KEY"] = "6LdSswwTAAAAADs20eK6NqYaeppxIWm-gJrpto0l"
    app.config["RECAPTCHA_PUBLIC_KEY"] = "6LdSswwTAAAAABTZq5Za_0blmaSpcg-dFcqaGda9"

    if config:
        app.config.from_object(config)

    app.config["ASSETS_DEBUG"] = app.config["DEBUG"]

    db.init_app(app)
    migrate.init_app(app, db)
    assets.init_app(app)
    jwt.init_app(app)

    assets.register("js", js)
    assets.register("css", css)

    app.register_blueprint(main)
    app.register_blueprint(api, url_prefix="/api")
    app.register_blueprint(auth, url_prefix="/auth")

    return app
Example #13
0
    def test_exception_header_forwarded(self):
        """Test that HTTPException's headers are extended properly"""
        app = Flask(__name__)
        app.config["DEBUG"] = True
        api = flask_restful.Api(app)

        class NotModified(HTTPException):
            code = 304

            def __init__(self, etag, *args, **kwargs):
                super(NotModified, self).__init__(*args, **kwargs)
                self.etag = quote_etag(etag)

            def get_headers(self, *args, **kwargs):
                """Get a list of headers."""
                return [("ETag", self.etag)]

        class Foo1(flask_restful.Resource):
            def get(self):
                flask_abort(304, etag="myETag")

        api.add_resource(Foo1, "/foo")
        flask_abort.mapping.update({304: NotModified})

        with app.test_client() as client:
            foo = client.get("/foo")
            self.assertEquals(foo.get_etag(), unquote_etag(quote_etag("myETag")))
Example #14
0
    def setUp(self):
        """Creates the Flask application and the APIManager."""
        # create the Flask application
        app = Flask(__name__)
        app.config["DEBUG"] = True
        app.config["TESTING"] = True
        app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite://"
        app.logger.disabled = True
        self.flaskapp = app

        # create the test client
        self.app = app.test_client()

        # Ensure that all requests have Content-Type set to "application/json"
        # unless otherwise specified.
        for methodname in ("get", "put", "patch", "post", "delete"):
            # Create a decorator for the test client request methods that adds
            # a JSON Content-Type by default if none is specified.
            def set_content_type(func):
                def new_func(*args, **kw):
                    if "content_type" not in kw:
                        kw["content_type"] = "application/json"
                    return func(*args, **kw)

                return new_func

            # Decorate the original test client request method.
            old_method = getattr(self.app, methodname)
            setattr(self.app, methodname, set_content_type(old_method))
Example #15
0
 def create_app(self):
     app = Flask("test")
     app.register_blueprint(blueprint, url_prefix="/bbg")
     app.config["DEBUG"] = True
     app.config["TESTING"] = True
     app.config["PRESERVE_CONTEXT_ON_EXCEPTION"] = True
     return app
Example #16
0
 def setUp(self):
     """Setup up."""
     app = Flask(__name__)
     app.config["DEBUG"] = True
     app.config["TESTING"] = True
     app.logger.disabled = True
     self.app = app
Example #17
0
def create():
    """Create application.
    """

    # Create application
    app = Flask("service", static_folder=None)
    app.config["DEBUG"] = True

    # CORS support
    CORS(app)

    # Session
    sess = Session()
    app.config["SESSION_TYPE"] = "filesystem"
    app.config["SECRET_KEY"] = "openspending rocks"
    sess.init_app(app)

    # Register blueprints
    print("Creating Datastore Blueprint")
    app.register_blueprint(datastore.create(), url_prefix="/datastore")
    print("Creating API Loader Blueprint")
    app.register_blueprint(apiload.create(), url_prefix="/hooks/load/")
    print("Creating Authentication Blueprint")
    app.register_blueprint(authentication.create(), url_prefix="/oauth/")
    print("Creating Authorization Blueprint")
    app.register_blueprint(authorization.create(), url_prefix="/permit/")
    print("Creating Search Blueprint")
    app.register_blueprint(search.create(), url_prefix="/search/")

    # Return application
    return app
Example #18
0
def create_app(config=Config()):
    """Flask application factory."""

    app = Flask(__name__)

    if config is not None:
        app.config.from_object(config)

    # override settings by environment variables

    if "DEBUG" in os.environ:
        app.config["DEBUG"] = os.environ["DEBUG"].lower() == "true"

    if "SECRET_KEY" in os.environ:
        app.config["SECRET_KEY"] = os.environ["SECRET_KEY"]

    if "SSL_ENABLE_REDIRECTS" in os.environ:
        app.config["SSL_ENABLE_REDIRECTS"] = os.environ["SSL_ENABLE_REDIRECTS"].lower() == "true"

    if "DATABASE_URL" in os.environ:
        app.config["SQLALCHEMY_DATABASE_URI"] = os.environ["DATABASE_URL"]

    db.init_app(app)
    babel = Babel(app)
    login_manager.setup_app(app)
    oid.init_app(app)
    DebugToolbarExtension(app)

    app.register_blueprint(times)

    admin = Admin(app, url_prefix="/admin", title="Admin")
    admin.add_path_security("/", secure_admin_path)
    admin.add_path_security("/auth", secure_admin_auth_path)

    auth_node = admin.register_node("/auth", "auth", "Authentication")
    time_node = admin.register_node("/time_node", "time_node", "Times")

    admin.register_module(UserAdmin, "/users", "users", "Users", parent=auth_node)
    admin.register_module(CompanyAdmin, "/companies", "companies", "Companies", parent=time_node)
    admin.register_module(ProjectAdmin, "/projects", "projects", "Projects", parent=time_node)
    admin.register_module(TaskAdmin, "/tasks", "tasks", "Tasks", parent=time_node)
    admin.register_module(WorkingUnitAdmin, "/times", "times", "Working Times", parent=time_node)

    @login_manager.user_loader
    def load_user(userid):
        return User.query.get(int(userid))

    @app.context_processor
    def inject_context():
        version = os.environ.get("VERSION", "devel")
        return dict(user=current_user, now=datetime.now(), version=version)

    @babel.localeselector
    def get_locale():
        if hasattr(current_user, "locale"):
            return current_user.locale
        return request.accept_languages.best_match(["en", "ja", "de"])

    return app
def create_app():
    app = Flask(__name__, static_folder="statics", template_folder="templates")
    app.config["DEBUG"] = True
    app.config["SECRET_KEY"] = "Some Secret Key"

    app.register_blueprint(index.blueprint, url_prefix="")

    return app
Example #20
0
def web_app():
    app = Flask(__name__)
    app.config["DEBUG"] = DEBUG

    api = Api(app)
    api.add_resource(RandomName, "/getnames/<int:total_name>")

    return app
Example #21
0
def create_flask_app():
    """Creates a configured flask app."""
    app = Flask(__name__, template_folder="templates")
    app.debug = True
    app.secret_key = "secret"
    app.config["DEBUG"] = True

    return app
Example #22
0
def main():
    if len(sys.argv) > 1:
        _mockdown.root = sys.argv[1]

    app = Flask(__name__)
    app.config["DEBUG"] = True
    app.register_blueprint(mockdown_app)
    app.run()
Example #23
0
def create_app(app_name="web_app"):
    app = Flask(app_name)
    CORS(app)

    app.config["DEBUG"] = True
    app.register_blueprint(api)
    app.redis = redis.StrictRedis(host="localhost", port=6379, db=0)
    return app
Example #24
0
def create_app(_run_mode=None):
    # Create Flask app.
    global app
    base_dir = os.path.dirname(os.path.abspath(__file__))
    template_dir = os.path.join(base_dir, "templates")
    static_dir = os.path.join(base_dir, "static")
    app = Flask("procjam15", template_folder=template_dir, static_folder=static_dir)

    # Dev run mode.
    if _run_mode == "dev":
        app.config["DEBUG"] = True
        app.config["SECRET_KEY"] = "WeDontCareAboutSecretsInDev"

    # Heroku run mode.
    elif _run_mode == "heroku":
        # Get port number and secret key from Heroku environment variable.
        app.config["PORT_NR"] = int(os.environ["PORT"])
        app.config["SECRET_KEY"] = os.environ["FLASK_SECRET_KEY"]
        app.config["DEBUG"] = False

        init_stdout_handler()
        set_up_logger(app.logger)

    # Dreamhost run mode.
    elif _run_mode == "dreamhost":
        # Get port number and secret key from Heroku environment variable.
        app.config["SECRET_KEY"] = os.environ["FLASK_SECRET_KEY"]
        app.config["DEBUG"] = False

        init_stdout_handler()
        set_up_logger(app.logger)

    # Unrecognized run mode.
    else:
        logging.error("Did not recognize run mode '%s'." % _run_mode)
        return None

    app.debug = app.config["DEBUG"]

    # Import the views, to apply the decorators which use the global app object.
    import main.views

    # Set up Jinja 2 filters.
    set_up_jinja_filters(app)

    return app
 def create_app(self):
     config._set_connection_string("sqlite:///test.db")
     app = Flask("test")
     app.register_blueprint(FDPLoaderBlueprint, url_prefix="/loader")
     app.config["DEBUG"] = True
     app.config["TESTING"] = True
     app.config["PRESERVE_CONTEXT_ON_EXCEPTION"] = True
     return app
Example #26
0
def create_app():
    app = Flask(__name__)
    app.register_blueprint(bp)
    app.config["DEBUG"] = True
    app.config["DATABASE"] = ":memory:"
    app.config["SECRET_KEY"] = "wow"
    db.init_app(app)
    return app
Example #27
0
    def __init__(self):
        print("Started WebApp")

        # to disable RuntimeWarning: This channel is already in use
        GPIO.setwarnings(False)

        GPIO.setmode(GPIO.BCM)
        # para usar o LED da placa (GPIO 47), fazer:
        # sudo sh -c "echo gpio >/sys/class/leds/led0/trigger"
        # para repor o comportamento habitual, fazer
        # sudo sh -c "echo mmc0 >/sys/class/leds/led0/trigger"
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23, GPIO.LOW)
        GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

        GPIO.add_event_detect(18, GPIO.BOTH, callback=self.onButton)

        app = Flask(__name__)
        Bootstrap(app)
        app.config["DEBUG"] = False
        self.socketio = SocketIO(app)
        self.counter = -1

        @app.before_first_request
        def initialize():
            print("Called only once, when the first request comes in")

        @app.route("/")
        def index():
            print("render index.html")
            return render_template("index2.html", board="Raspberry Pi")

        @self.socketio.on("connect", namespace="/test")
        def test_connect():
            self.counter += 1
            print("Counter= {0}".format(self.counter))
            print("Client connected")

        @self.socketio.on("disconnect", namespace="/test")
        def test_disconnect():
            self.counter -= 1
            print("Counter= {0}".format(self.counter))
            print("Client disconnected")

        @self.socketio.on("getVersion", namespace="/test")
        def getVersion():
            print("version")

        @self.socketio.on("ledRCtrl", namespace="/test")
        def ledRCtrl(message):
            print(message["led"])
            GPIO.output(23, GPIO.HIGH if message["led"] else GPIO.LOW)
            if GPIO.input(18):
                print("Input was HIGH")
            else:
                print("Input was LOW")

        self.socketio.run(app, host="0.0.0.0", port=5001)
Example #28
0
def create_app():
    app = Flask(__name__)
    app.config["DEBUG"] = True
    app.config[
        "SQLALCHEMY_DATABASE_URI"
    ] = "sqlite:////Users/olivergoodman/Documents/github/app-blueprint/my_app/personal.db"
    db.init_app(app)
    app.register_blueprint(hello, url_prefix="")
    return app
Example #29
0
    def __init__(self):
        print("Started webledbut")

        self.thread = None

        # to disable RuntimeWarning: This channel is already in use
        GPIO.setwarnings(False)

        GPIO.setmode(GPIO.BCM)
        GPIO.setup(23, GPIO.OUT)
        GPIO.output(23, GPIO.LOW)
        GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

        app = Flask(__name__)
        Bootstrap(app)
        app.config["DEBUG"] = False
        self.socketio = SocketIO(app, async_mode="eventlet")
        self.counter = 0

        print("Begin thread")
        if self.thread is None:
            print("create thread")
            thread = Thread(target=self.background_thread)
            thread.daemon = True
            thread.start()

        @app.before_first_request
        def initialize():
            print("Called only once, when the first request comes in")

        @app.route("/")
        def index():
            print("render index.html")
            return render_template("index.html", board="Raspberry Pi")

        @self.socketio.on("connect", namespace="/test")
        def test_connect():
            self.counter += 1
            print("Counter= {0}".format(self.counter))
            print("Client connected")

        @self.socketio.on("disconnect", namespace="/test")
        def test_disconnect():
            self.counter -= 1
            print("Counter= {0}".format(self.counter))
            print("Client disconnected")

        @self.socketio.on("getVersion", namespace="/test")
        def getversion():
            print("version")

        @self.socketio.on("ledRCtrl", namespace="/test")
        def ledrctrl(message):
            print(message["led"])
            GPIO.output(23, GPIO.HIGH if message["led"] else GPIO.LOW)

        self.socketio.run(app, host="0.0.0.0", port=5001)
Example #30
0
def create_app():
    app = Flask(__name__)
    app.config["DEBUG"] = True
    app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///webapp/example.db"

    db.init_app(app)
    register_blueprints(app)

    return app