• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python web.RequestHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tornado.web.RequestHandler的典型用法代码示例。如果您正苦于以下问题:Python RequestHandler类的具体用法?Python RequestHandler怎么用?Python RequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了RequestHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: write_error

 def write_error(self, *args, **kwargs):
     '''
     Must override base write error to stop uncaught
     HTTP errors from clearing CORS headers
     '''
     self.write_cors_headers()
     RequestHandler.write_error(self, *args, **kwargs)
开发者ID:i-Dynamics,项目名称:Talk-A2Z,代码行数:7,代码来源:remote_sign_in_handler.py


示例2: check_xsrf_cookie

    def check_xsrf_cookie(self):
        if self.application.testing_key \
        and self.request.headers.get('X-Testing-Key') \
        == self.application.testing_key:
            return

        RequestHandler.check_xsrf_cookie(self)
开发者ID:chfoo,项目名称:www,代码行数:7,代码来源:base.py


示例3: finish

 def finish(self, chunk=None):
     '''
     重写服务的finish, 并存储返回值
     '''
     
     RequestHandler.finish(self, chunk=chunk)
     self.return_value = chunk
开发者ID:hljxuege,项目名称:myworkplace,代码行数:7,代码来源:tornado_async_with_redis_mongo_mysql.py


示例4: render

    def render(self, template_name, **kwargs):
        params = dict()
        for key, val in self.request.arguments.items():
            params[key] = ','.join(val) if isinstance(val, list) else val

        kwargs["params"] = params
        kwargs["json_dict"] = json_to_dict
        RequestHandler.render(self, template_name, **kwargs)
开发者ID:ikewang,项目名称:WebTester,代码行数:8,代码来源:basic_handler.py


示例5: write_error

 def write_error(self, status_code, **kwargs):
     try:
         error_env = Environment(loader = FileSystemLoader(self.__project_path + '/public'))
         temp = error_env.get_template(str(status_code) + '.html')
         self.write(temp.render())
     except TemplateNotFound:
         RequestHandler.write_error(self, status_code, **kwargs)
开发者ID:far-rel,项目名称:Pails,代码行数:7,代码来源:BaseHandler.py


示例6: __init__

 def __init__(self, application, request):
     RequestHandler.__init__(self, application, request)
     self._current_user = None
     self.middleware_manager = MiddlewareManager(self)
     self._is_threaded = False
     self._is_whirlwind_finished = False
     self.view = {}
开发者ID:strogo,项目名称:whirlwind,代码行数:7,代码来源:request.py


示例7: write

    def write(self, payload, passthru=False):
        if passthru:
            return RequestHandler.write(self, payload)

        self.set_header('Content-Type', 'application/json; charset=UTF-8')
        RequestHandler.write(self, json.dumps(payload, indent=options.debug and 2 or None,
                                              default=_ToJSONMixin.json_default))
开发者ID:rfw,项目名称:entranced,代码行数:7,代码来源:web.py


示例8: _handle_request_exception

    def _handle_request_exception(self, exc):

        options = {
            "user": {"id": self.request.remote_ip},
            "context": self._get_context(),
            "request": {
                "url": self.request.full_url(),
                "method": self.request.method,
                "arguments": self.request.arguments,
            },
            "severity_reason": {
                "type": "unhandledExceptionMiddleware",
                "attributes": {
                    "framework": "Tornado"
                }
            }
        }

        # Notify bugsnag, unless it's an HTTPError that we specifically want
        # to ignore
        should_notify_bugsnag = True
        if type(exc) == HTTPError:
            ignore_status_codes = self.bugsnag_ignore_status_codes()
            if ignore_status_codes and exc.status_code in ignore_status_codes:
                should_notify_bugsnag = False

        if should_notify_bugsnag:
            bugsnag.auto_notify(exc, **options)

        # Call the parent handler
        RequestHandler._handle_request_exception(self, exc)
开发者ID:bugsnag,项目名称:bugsnag-python,代码行数:31,代码来源:__init__.py


示例9: write_error

 def write_error(self, status_code, **kwargs):
     if status_code == 404:
         self.render('404.html')
     elif status_code >= 500 and status_code < 600:
         self.render('500.html')
     else:
         RequestHandler.write_error(self, status_code, **kwargs)
开发者ID:hzx,项目名称:wender,代码行数:7,代码来源:handlers.py


示例10: initialize

 def initialize(self, html_template=None, js_template=None, cors_origins=None):
     RequestHandler.initialize(self)
     self.set_cors_methods("OPTIONS,GET,POST")
     if cors_origins:
         self.set_cors_whitelist(cors_origins)
     self._html_template = html_template
     self._js_template = js_template
开发者ID:Divide-Zero,项目名称:Photo-Stream-Server,代码行数:7,代码来源:rpc_handler.py


示例11: prepare

 def prepare(self):
     """
         Prepare the request
     """
     RequestHandler.prepare(self)
     self.model.session.expunge_all() # Always start a request fresh.
     self._call_preprocessor()
开发者ID:fabioz,项目名称:tornado-restless,代码行数:7,代码来源:handler.py


示例12: test_on_request

    def test_on_request(self):

        app = Application()
        request = HTTPRequest('POST', '/collector?hello=world', body=b"foo=bar&bar=foo", headers={'Content-Type': 'application/x-www-form-urlencoded'}, connection=get_dummy_connection())

        handler = RequestHandler(app, request)
        handler.run = Run()

        self.collector.on_request(handler, handler.run)

        self.assertEquals({
            'body_arguments': {},
            'cookies': '',
            'headers': {'Content-Type': 'application/x-www-form-urlencoded'},
            'host': '127.0.0.1',
            'method': 'POST',
            'path': '/collector',
            'protocol': 'http',
            'query': 'hello=world',
            'body': 'foo=bar&bar=foo',
            'query_arguments': {'hello': ['world']},
            'remote_ip': '127.0.0.1',
            'uri': '/collector?hello=world',
            'version': 'HTTP/1.0',
            'controller': {'class': False, 'file': False, 'line': False, 'method': False},
            'route': False,
            'status_code': False,
        }, handler.run.get_metric('request'))
开发者ID:alexmerser,项目名称:python-element,代码行数:28,代码来源:test_collector.py


示例13: write

 def write(self, chunk):
     if isinstance(chunk, dict) and self.settings.get('debug'):
         RequestHandler.write(self, json.dumps(chunk, indent=4))
     else:
         RequestHandler.write(self, chunk)
     if isinstance(chunk, dict):
         self.set_header('Content-Type', self._ct('json'))
开发者ID:Geew,项目名称:shoppingDemo,代码行数:7,代码来源:base.py


示例14: _execute

 def _execute(self, transforms, *args, **kwargs):
     ''' select base handler for self '''
     with LogicContext():
         if isinstance(self, WebSocketHandler):
             WebSocketHandler._execute(self, transforms, *args, **kwargs)
         elif isinstance(self, RequestHandler):
             RequestHandler._execute(self, transforms, *args, **kwargs)
开发者ID:FashtimeDotCom,项目名称:kpages,代码行数:7,代码来源:context.py


示例15: set_user_cookie

def set_user_cookie(app, request, username):
    from tornado.web import RequestHandler
    r = RequestHandler(app, request)
    r.set_secure_cookie('user', username)
    authcookie = r._new_cookies[0]
    cookiestring = authcookie.items()[0][1]
    request.cookies.update({'user': cookiestring})
    return request
开发者ID:chaosbaby,项目名称:SimpleMMO,代码行数:8,代码来源:test_zoneserver.py


示例16: write_error

 def write_error(self, status_code, **kwargs):
     if 'exc_info' in kwargs:
         typ, value, tb = kwargs['exc_info']
         if isinstance(value, PermissionError):
             self.set_status(403)
             self.write('PermissionError')
             return
     RequestHandler.write_error(self, status_code, **kwargs)
开发者ID:akkakks,项目名称:tornado,代码行数:8,代码来源:web_test.py


示例17: write_error

 def write_error(self, code, **kwargs):
     exc_type, exc_value, _exc_tb = kwargs.get('exc_info', [None] * 3)
     if exc_type is not None and issubclass(exc_type, HTTPError):
         self.set_header('Content-Type', 'text/plain')
         if exc_value.log_message:
             self.write(exc_value.log_message + '\n')
     else:
         RequestHandler.write_error(self, code, **kwargs)
开发者ID:cmusatyalab,项目名称:opendiamond,代码行数:8,代码来源:handlers.py


示例18: __init__

	def __init__(self, application, request):
		RequestHandler.__init__(self, application, request)
		self._current_user = None
		self.middleware_manager = MiddlewareManager(self)
		self._is_threaded = False
		self._is_whirlwind_finished = False
		self.view = dotdict()
		self.db = Mongo.db.ui #@UndefinedVariable
开发者ID:Magic347,项目名称:whirlwind,代码行数:8,代码来源:request.py


示例19: render

 def render(self, template_name, **kwargs):
     kwargs.update(session=self.session)
     kwargs.update(config=self.configuration)
     kwargs.update(current_page=self.current_page)
     kwargs.update(has_nav=self.has_nav)
     kwargs.update(html5=self.html5)
     kwargs.update(rendered_time=self.rendered_time)
     kwargs.update(prefix_url=self.prefix_url)
     RequestHandler.render(self, template_name, **kwargs)
开发者ID:ergatea,项目名称:gitpub2,代码行数:9,代码来源:base.py


示例20: __init__

 def __init__(self, application, request, **kwargs):
     RequestHandler.__init__(self, application, request, **kwargs)
     _headers = self.request.headers
     self.mn_server = _headers.get(MN_INSTANCE_SERVER,'')
     self.mn_port = _headers.get(MN_INSTANCE_PORT,'')
     self.ProductID = _headers.get(MN_PRODUCT_ID,'')
     self._instance = application._instance
     self._search_count = 2
     self._not_found_callback = self._response_no_agent
开发者ID:Inexika,项目名称:MyNotes-Service,代码行数:9,代码来源:mn_instance.py



注:本文中的tornado.web.RequestHandler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python web.StaticFileHandler类代码示例发布时间:2022-05-27
下一篇:
Python web.Application类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap