Пример #1
0
def serve_schema_js(schema: APISchema, templates: Templates) -> http.Response:
    codec = CoreJSONCodec()
    base64_schema = base64.b64encode(codec.encode(schema)).decode('latin1')
    template = templates.get_template('apistar/schema.js')
    content = template.render(base64_schema=base64_schema)
    headers = {'Content-Type': 'application/javascript'}
    return http.Response(content, headers=headers)
Пример #2
0
def serve_schema_js(schema: APISchema, templates: Templates) -> http.Response:
    codec = CoreJSONCodec()
    base64_schema = base64.b64encode(codec.encode(schema)).decode('latin1')
    template = templates.get_template('apistar/schema.js')
    content = template.render(base64_schema=base64_schema)
    headers = {'Content-Type': 'application/javascript'}
    return http.Response(content, headers=headers)
Пример #3
0
 def mockreturn(self, request):
     codec = CoreJSONCodec()
     body = force_text(request.body)
     content = codec.encode(Document(content={'data': json.loads(body)}))
     return MockResponse(content)
Пример #4
0
def serve_schema(schema: APISchema) -> http.Response:
    codec = CoreJSONCodec()
    content = codec.encode(schema)
    headers = {'Content-Type': codec.media_type}
    return http.Response(content, headers=headers)
Пример #5
0
def serve_schema(schema: APISchema) -> http.Response:
    codec = CoreJSONCodec()
    content = codec.encode(schema)
    headers = {'Content-Type': codec.media_type}
    return http.Response(content, headers=headers)