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

Python wsgiservice.get_app函数代码示例

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

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



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

示例1: test_modified_generate

def test_modified_generate():
    """Resource generates a good Last-Modified response header."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4?id=myid')
    res = app._handle_request(req)
    print res._headers
    assert res._headers['Last-Modified'] == 'Fri, 01 May 2009 14:30:00 GMT'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:7,代码来源:test_application.py


示例2: test_etag_generate_json_ext

def test_etag_generate_json_ext():
    """ETags are calculated by adding the extension to the custom etag."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4.json?id=myid')
    res = app._handle_request(req)
    print res
    assert res._headers['ETag'] == '"myid_json"'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:7,代码来源:test_application.py


示例3: test_exception_json

def test_exception_json():
    """An exception is serialized as a dictionary in JSON."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res5?throw=1', {'HTTP_ACCEPT': 'application/json'})
    res = app._handle_request(req)
    print res
    assert res.status == '500 Internal Server Error'
    assert res.body == '{"error": "Some random exception."}'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例4: test_res6_default

def test_res6_default():
    """Resource6 works normally for keys which exist on the resource."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res6/uid')
    res = app._handle_request(req)
    print res
    assert res.status == '200 OK'
    assert res.body == '<response>works</response>'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例5: test_etag_if_match_not_set

def test_etag_if_match_not_set():
    """A GET request without an If-Match header passes."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4?id=myid')
    res = app._handle_request(req)
    print res
    assert res._headers['ETag'] == '"myid_xml"'
    assert res.status == '200 OK'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例6: test_etag_if_match_true

def test_etag_if_match_true():
    """A GET request with a matching If-Match passes."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4?id=myid', {'HTTP_IF_MATCH': '"myid_xml"'})
    res = app._handle_request(req)
    print res
    assert res._headers['ETag'] == '"myid_xml"'
    assert res.status == '200 OK'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例7: test_with_expires

def test_with_expires():
    """expires decorator correctly sets the Cache-Control header."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res3')
    res = app._handle_request(req)
    print str(res)
    print res._headers
    assert res._headers['Cache-Control'] == 'max-age=86400'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例8: test_notfound_xml

def test_notfound_xml():
    """Requests that cause a NOT_FOUND exception return 404."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res6/foo')
    res = app._handle_request(req)
    print res
    assert res.status == '404 Not Found'
    assert res.body == '<response><error>Not Found</error></response>'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例9: test_with_expires_calculations

def test_with_expires_calculations():
    """expires decorator correctly sets the Expires header."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4')
    res = app._handle_request(req)
    print res._headers
    assert res._headers['Cache-Control'] == 'max-age=138'
    assert res._headers['Expires'] == 'Mon, 20 Apr 2009 17:55:45 GMT'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例10: test_app_handle_404

def test_app_handle_404():
    """Application returns a 404 status code if no resource is found."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/foo')
    res = app._handle_request(req)
    print res
    assert res.status == '404 Not Found'
    assert res.body == ''
开发者ID:marcammann,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例11: test_app_handle_options

def test_app_handle_options():
    """Resource provides a good default for the OPTIONS method."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res2', {'REQUEST_METHOD': 'OPTIONS'})
    res = app._handle_request(req)
    print res
    assert res.status == '200 OK'
    assert res._headers['Allow'] == 'OPTIONS, POST, PUT'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:8,代码来源:test_application.py


示例12: test_etag_if_match_false

def test_etag_if_match_false():
    """A GET request with a non-matching If-Match returns 412."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4?id=myid',
        {'HTTP_IF_MATCH': '"otherid"'})
    res = app._handle_request(req)
    print res
    assert res._headers['ETag'] == '"myid_xml"'
    assert res.status == '412 Precondition Failed'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例13: test_with_expires_calculations_double_wrapped

def test_with_expires_calculations_double_wrapped():
    """Wrapped expires decorators work by just using the last one."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4', {'REQUEST_METHOD': 'POST'})
    res = app._handle_request(req)
    print str(res)
    print res._headers
    assert res._headers['Cache-Control'] == 'max-age=138'
    assert res._headers['Expires'] == 'Mon, 20 Apr 2009 17:55:45 GMT'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例14: test_with_expires_vary

def test_with_expires_vary():
    """expires decorator can set the Vary header."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res6/uid')
    res = app._handle_request(req)
    print str(res)
    print res._headers
    assert res._headers['Cache-Control'] == 'max-age=86400'
    assert res._headers['Vary'] == 'Authorization, Accept'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例15: test_verify_content_md5_valid

def test_verify_content_md5_valid():
    """A request with a body that matches Content-MD5 passes."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res1/theid', {
        'HTTP_CONTENT_MD5': '89d5739baabbbe65be35cbe61c88e06d',
        'wsgi.input': StringIO.StringIO('Foobar')})
    res = app._handle_request(req)
    print res
    assert res.status == '200 OK'
开发者ID:marcammann,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例16: test_etag_if_none_match_false

def test_etag_if_none_match_false():
    """A GET request with a non-matching If-None-Match executes normally."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4?id=myid',
        {'HTTP_IF_NONE_MATCH': '"otherid"'})
    res = app._handle_request(req)
    print res
    assert res._headers['ETag'] == '"myid_xml"'
    assert res.status == '200 OK'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例17: test_etag_if_none_match_post_true

def test_etag_if_none_match_post_true():
    """A POST request with a matching If-None-Match returns 412."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res4?id=myid',
        {'HTTP_IF_NONE_MATCH': '"myid_xml"', 'REQUEST_METHOD': 'POST'})
    res = app._handle_request(req)
    print res
    assert res._headers['ETag'] == '"myid_xml"'
    assert res.status == '412 Precondition Failed'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例18: test_app_handle_response_201_ext

def test_app_handle_response_201_ext():
    """raise_201 ignores extension in the current path."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res2.json', {'REQUEST_METHOD': 'PUT'})
    res = app._handle_request(req)
    print res
    assert res.status == '201 Created'
    assert res.body == ''
    assert res.location == '/res2/foo'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py


示例19: test_post_xml_object_fail

def test_post_xml_object_fail():
    """Create object with XML request body not supported"""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/humans', {'REQUEST_METHOD': 'POST', 'HTTP_ACCEPT': 'application/xml'})
    req.content_type = 'application/xml'
    req.body = "<name>patrice</name>"
    res = app._handle_request(req)
    print res
    assert res.status == '400 Bad Request'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_jsonbody.py


示例20: test_app_handle_response_201_abs

def test_app_handle_response_201_abs():
    """raise_201 used the location header directly if it is absolute."""
    app = wsgiservice.get_app(globals())
    req = Request.blank('/res2', {'REQUEST_METHOD': 'POST'})
    res = app._handle_request(req)
    print res
    assert res.status == '201 Created'
    assert res.body == ''
    assert res.location == '/res2/test'
开发者ID:fotonobile,项目名称:wsgiservice,代码行数:9,代码来源:test_application.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python wskutil.apiBase函数代码示例发布时间:2022-05-26
下一篇:
Python validate.validator函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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