當前位置: 首頁>>代碼示例>>Python>>正文


Python myapp.app方法代碼示例

本文整理匯總了Python中myapp.app方法的典型用法代碼示例。如果您正苦於以下問題:Python myapp.app方法的具體用法?Python myapp.app怎麽用?Python myapp.app使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在myapp的用法示例。


在下文中一共展示了myapp.app方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def __init__(self, app, evalex=False, request_key='werkzeug.request',
                 console_path='/console', console_init_func=None,
                 show_hidden_frames=False, lodgeit_url=None):
        if lodgeit_url is not None:
            from warnings import warn
            warn(DeprecationWarning('Werkzeug now pastes into gists.'))
        if not console_init_func:
            console_init_func = dict
        self.app = app
        self.evalex = evalex
        self.frames = {}
        self.tracebacks = {}
        self.request_key = request_key
        self.console_path = console_path
        self.console_init_func = console_init_func
        self.show_hidden_frames = show_hidden_frames
        self.secret = gen_salt(20) 
開發者ID:chalasr,項目名稱:Flask-P2P,代碼行數:19,代碼來源:__init__.py

示例2: _get_pin

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def _get_pin(self):
        if not hasattr(self, "_pin"):
            self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app)
        return self._pin 
開發者ID:PacktPublishing,項目名稱:Building-Recommendation-Systems-with-Python,代碼行數:6,代碼來源:__init__.py

示例3: pin_cookie_name

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def pin_cookie_name(self):
        """The name of the pin cookie."""
        if not hasattr(self, "_pin_cookie"):
            self._pin, self._pin_cookie = get_pin_and_cookie_name(self.app)
        return self._pin_cookie 
開發者ID:PacktPublishing,項目名稱:Building-Recommendation-Systems-with-Python,代碼行數:7,代碼來源:__init__.py

示例4: display_console

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def display_console(self, request):
        """Display a standalone shell."""
        if 0 not in self.frames:
            if self.console_init_func is None:
                ns = {}
            else:
                ns = dict(self.console_init_func())
            ns.setdefault("app", self.app)
            self.frames[0] = _ConsoleFrame(ns)
        is_trusted = bool(self.check_pin_trust(request.environ))
        return Response(
            render_console_html(secret=self.secret, evalex_trusted=is_trusted),
            mimetype="text/html",
        ) 
開發者ID:PacktPublishing,項目名稱:Building-Recommendation-Systems-with-Python,代碼行數:16,代碼來源:__init__.py

示例5: debug_application

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def debug_application(self, environ, start_response):
        """Run the application and conserve the traceback frames."""
        app_iter = None
        try:
            app_iter = self.app(environ, start_response)
            for item in app_iter:
                yield item
            if hasattr(app_iter, 'close'):
                app_iter.close()
        except Exception:
            if hasattr(app_iter, 'close'):
                app_iter.close()
            traceback = get_current_traceback(skip=1, show_hidden_frames=
                                              self.show_hidden_frames,
                                              ignore_system_exceptions=True)
            for frame in traceback.frames:
                self.frames[frame.id] = frame
            self.tracebacks[traceback.id] = traceback

            try:
                start_response('500 INTERNAL SERVER ERROR', [
                    ('Content-Type', 'text/html; charset=utf-8'),
                    # Disable Chrome's XSS protection, the debug
                    # output can cause false-positives.
                    ('X-XSS-Protection', '0'),
                ])
            except Exception:
                # if we end up here there has been output but an error
                # occurred.  in that situation we can do nothing fancy any
                # more, better log something into the error log and fall
                # back gracefully.
                environ['wsgi.errors'].write(
                    'Debugging middleware caught exception in streamed '
                    'response at a point where response headers were already '
                    'sent.\n')
            else:
                yield traceback.render_full(evalex=self.evalex,
                                            secret=self.secret) \
                               .encode('utf-8', 'replace')

            traceback.log(environ['wsgi.errors']) 
開發者ID:chalasr,項目名稱:Flask-P2P,代碼行數:43,代碼來源:__init__.py

示例6: __init__

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def __init__(
        self,
        app,
        evalex=False,
        request_key="werkzeug.request",
        console_path="/console",
        console_init_func=None,
        show_hidden_frames=False,
        lodgeit_url=None,
        pin_security=True,
        pin_logging=True,
    ):
        if lodgeit_url is not None:
            from warnings import warn

            warn(
                "'lodgeit_url' is no longer used as of version 0.9 and"
                " will be removed in version 1.0. Werkzeug uses"
                " https://gist.github.com/ instead.",
                DeprecationWarning,
                stacklevel=2,
            )
        if not console_init_func:
            console_init_func = None
        self.app = app
        self.evalex = evalex
        self.frames = {}
        self.tracebacks = {}
        self.request_key = request_key
        self.console_path = console_path
        self.console_init_func = console_init_func
        self.show_hidden_frames = show_hidden_frames
        self.secret = gen_salt(20)
        self._failed_pin_auth = 0

        self.pin_logging = pin_logging
        if pin_security:
            # Print out the pin for the debugger on standard out.
            if os.environ.get("WERKZEUG_RUN_MAIN") == "true" and pin_logging:
                _log("warning", " * Debugger is active!")
                if self.pin is None:
                    _log("warning", " * Debugger PIN disabled. DEBUGGER UNSECURED!")
                else:
                    _log("info", " * Debugger PIN: %s" % self.pin)
        else:
            self.pin = None 
開發者ID:PacktPublishing,項目名稱:Building-Recommendation-Systems-with-Python,代碼行數:48,代碼來源:__init__.py

示例7: debug_application

# 需要導入模塊: import myapp [as 別名]
# 或者: from myapp import app [as 別名]
def debug_application(self, environ, start_response):
        """Run the application and conserve the traceback frames."""
        app_iter = None
        try:
            app_iter = self.app(environ, start_response)
            for item in app_iter:
                yield item
            if hasattr(app_iter, "close"):
                app_iter.close()
        except Exception:
            if hasattr(app_iter, "close"):
                app_iter.close()
            traceback = get_current_traceback(
                skip=1,
                show_hidden_frames=self.show_hidden_frames,
                ignore_system_exceptions=True,
            )
            for frame in traceback.frames:
                self.frames[frame.id] = frame
            self.tracebacks[traceback.id] = traceback

            try:
                start_response(
                    "500 INTERNAL SERVER ERROR",
                    [
                        ("Content-Type", "text/html; charset=utf-8"),
                        # Disable Chrome's XSS protection, the debug
                        # output can cause false-positives.
                        ("X-XSS-Protection", "0"),
                    ],
                )
            except Exception:
                # if we end up here there has been output but an error
                # occurred.  in that situation we can do nothing fancy any
                # more, better log something into the error log and fall
                # back gracefully.
                environ["wsgi.errors"].write(
                    "Debugging middleware caught exception in streamed "
                    "response at a point where response headers were already "
                    "sent.\n"
                )
            else:
                is_trusted = bool(self.check_pin_trust(environ))
                yield traceback.render_full(
                    evalex=self.evalex, evalex_trusted=is_trusted, secret=self.secret
                ).encode("utf-8", "replace")

            traceback.log(environ["wsgi.errors"]) 
開發者ID:PacktPublishing,項目名稱:Building-Recommendation-Systems-with-Python,代碼行數:50,代碼來源:__init__.py


注:本文中的myapp.app方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。