Python flask.Flask 模块,__init__() 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用flask.Flask.__init__()

项目:fleaker    作者:croscon    | 项目源码 | 文件源码
def _whitelist_standard_flask_kwargs(cls, kwargs):
        """Whitelist a dictionary of kwargs to remove any that are not valid
        for Flask's ``__init__`` constructor.

        Since many Fleaker app mixins define their own kwargs for use in
        construction and Flask itself does not accept ``**kwargs``, we need to
        whitelist anything unknown.

        Uses the proper argspec from the :meth:`flask.Flask.__init__` so it
        should handle all args.

        Args:
            kwargs (dict): The dictionary of kwargs you want to whitelist.

        Returns:
            dict: The whitelisted dictionary of kwargs.
        """
        # prevent any copy shenanigans from happening
        kwargs = deepcopy(kwargs)

        if not cls._flask_init_argspec_cache:
            cls._flask_init_argspec_cache = inspect.getargspec(Flask.__init__)

        return {key: val for key, val in iteritems(kwargs)
                if key in cls._flask_init_argspec_cache.args}
项目:fleaker    作者:croscon    | 项目源码 | 文件源码
def pre_create_app(cls, **settings):
        """Run any logic that needs to be done strictly before the app has been
        made.

        The Pre Create Hook will be run immediately before :meth:`create_app`
        is run. It will be given the kwargs that were passed to
        :meth:`create_app` as it's kwargs. It is expected to return
        a dictionary of kwargs that will be passed to the actual App
        ``__init__`` call and to the :meth:`post_create_app` hook.

        Basically, this lets you hook in and parse or change settings
        dynamically. That's it's only goal and what it can do is up to you!

        .. admonition:: Make Sure You Call ``super``!

            A failure to call `super` in a hook method, such as the Pre Create
            Hook, is likely to break your **entire Fleaker App chain**! Make
            sure the very first, or very last, thing that your hook does is
            call `super`!
        """
        return settings
项目:Alexandria    作者:indrora    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        """
        LibConfig is essentially just a wrapper around
        a ConfigParser that reads the combined configuration
        files from the command line (typically).
        """
        self.localconf = ""
        self.baseconf = "" 
        self.parser = None
        self.tainted = False
        Config.__init__(self, *args, **kwargs)
项目:Alexandria    作者:indrora    | 项目源码 | 文件源码
def __init__(self,*args, **kwargs):
        Flask.__init__(self, *args, **kwargs)
项目:arc    作者:lap00zza    | 项目源码 | 文件源码
def __init__(self):
        Thread.__init__(self, daemon=True)
        self.loop = asyncio.get_event_loop()
        self.ws = None
项目:arc    作者:lap00zza    | 项目源码 | 文件源码
def __init__(self):
        self.store = {}
项目:arc    作者:lap00zza    | 项目源码 | 文件源码
def __init__(self):
        Flask.__init__(self, __name__)

        # Auth Initialization
        # NOTE: To invalidate all JWT's just change this secret.
        self.auth = Auth(os.environ.get("JWT_SECRET"), "HS256")

        # Database initialization
        self.db = DB()
        self.db.connect()

        # Register the routes
        # TODO: message rate limit 10 per 5 second
        self.route("/api", methods=["GET", "POST"])(self.index)
        self.route("/api/v1/myInfo", methods=["GET"])(self.my_info)
        self.route("/api/v1/channel/<channel_id>/messages", methods=["POST"])(self.messages)
        self.route("/api/v1/auth/login", methods=["POST"])(self.login)
        self.route("/api/v1/auth/register", methods=["POST"])(self.register)

        # start the ws client thread
        self.ws_client = WSClient()
        self.ws_client.start()

        # TODO: this is temporary redis replacement. Remove it later.
        self.mem_store = MemStore()

    # --- HELPER METHODS ---
项目:aw-server    作者:ActivityWatch    | 项目源码 | 文件源码
def __init__(self, name, *args, **kwargs):
        Flask.__init__(self, name, *args, **kwargs)

        # Is set on later initialization
        self.api = None  # type: ServerAPI
项目:BAR4Py    作者:bxtkezhan    | 项目源码 | 文件源码
def __init__(self, import_name):
        Flask.__init__(self, import_name=import_name)
        self.args = {}
        self.dictionary = None
        self.cameraParameters = None
        self.markerDetector = None

        with open(opjoin(opdirname(opabspath(__file__)), 'templates/index.tpl')) as f:
            self.template_string = f.read()

        self.js_libs = {}
        static_js_path = opjoin(opdirname(opabspath(__file__)), 'static/js')
        for filename in {'three.min.js', 'MTLLoader.js', 'OBJLoader.js', 'barviews.js'}:
            with open(opjoin(static_js_path, filename)) as f:
                self.js_libs[filename] = open(opjoin(static_js_path, filename)).read()
项目:BAR4Py    作者:bxtkezhan    | 项目源码 | 文件源码
def __init__(self, import_name):
        Flask.__init__(self, import_name=import_name)
        self.args = {}
        self.dictionary = None
        self.cameraParameters = None
        self.markerDetector = None

        with open(opjoin(opdirname(opabspath(__file__)), 'templates/index.tpl')) as f:
            self.template_string = f.read()

        self.js_libs = {}
        static_js_path = opjoin(opdirname(opabspath(__file__)), 'static/js')
        for filename in {'three.min.js', 'MTLLoader.js', 'OBJLoader.js', 'barviews.js'}:
            with open(opjoin(static_js_path, filename)) as f:
                self.js_libs[filename] = open(opjoin(static_js_path, filename)).read()
项目:BAR4Py    作者:bxtkezhan    | 项目源码 | 文件源码
def __init__(self, import_name):
        Flask.__init__(self, import_name=import_name)
        self.args = {}
        self.dictionary = None
        self.cameraParameters = None
        self.markerDetector = None

        with open(opjoin(opdirname(opabspath(__file__)), 'templates/index.tpl')) as f:
            self.template_string = f.read()

        self.js_libs = {}
        static_js_path = opjoin(opdirname(opabspath(__file__)), 'static/js')
        for filename in {'three.min.js', 'MTLLoader.js', 'OBJLoader.js', 'barviews.js'}:
            with open(opjoin(static_js_path, filename)) as f:
                self.js_libs[filename] = open(opjoin(static_js_path, filename)).read()
项目:BAR4Py    作者:bxtkezhan    | 项目源码 | 文件源码
def __init__(self, import_name):
        Flask.__init__(self, import_name=import_name)
        self.args = {}
        self.dictionary = None
        self.cameraParameters = None
        self.markerDetector = None

        with open(opjoin(opdirname(opabspath(__file__)), 'templates/index.tpl')) as f:
            self.template_string = f.read()

        self.js_libs = {}
        static_js_path = opjoin(opdirname(opabspath(__file__)), 'static/js')
        for filename in {'three.min.js', 'MTLLoader.js', 'OBJLoader.js', 'barviews.js'}:
            with open(opjoin(static_js_path, filename)) as f:
                self.js_libs[filename] = open(opjoin(static_js_path, filename)).read()
项目:alexandria    作者:LibraryBox-Dev    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        """
        LibConfig is essentially just a wrapper around
        a ConfigParser that reads the combined configuration
        files from the command line (typically).
        """
        self.localconf = ""
        self.baseconf = "" 
        self.parser = None
        self.tainted = False
        Config.__init__(self, *args, **kwargs)
项目:alexandria    作者:LibraryBox-Dev    | 项目源码 | 文件源码
def __init__(self,*args, **kwargs):
        Flask.__init__(self, *args, **kwargs)
项目:python-slack-events-api    作者:slackapi    | 项目源码 | 文件源码
def __init__(self, verification_token, endpoint, emitter):
        Flask.__init__(self, __name__)
        self.verification_token = verification_token

        @self.route(endpoint, methods=['GET', 'POST'])
        def event():
            # If a GET request is made, return 404.
            if request.method == 'GET':
                return make_response("These are not the slackbots you're looking for.", 404)

            # Parse the request payload into JSON
            event_data = json.loads(request.data.decode('utf-8'))

            # Echo the URL verification challenge code
            if "challenge" in event_data:
                return make_response(
                    event_data.get("challenge"), 200, {"content_type": "application/json"}
                )

            # Verify the request token
            request_token = event_data.get("token")
            if self.verification_token != request_token:
                emitter.emit('error', 'invalid verification token')
                return make_response("Request contains invalid Slack verification token", 403)

            # Parse the Event payload and emit the event to the event listener
            if "event" in event_data:
                event_type = event_data["event"]["type"]
                emitter.emit(event_type, event_data)
                return make_response("", 200)