Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
def serve_docs(schema: APISchema, templates: Templates, path: Path):
    index = templates.get_template('apistar/docs/index.html')
    langs = ['python', 'javascript', 'shell']

    def static(path):
        return '/static/' + path

    def get_fields(link, location):
        return [field for field in link.fields if field.location == location]

    return index.render(document=schema,
                        static=static,
                        langs=langs,
                        get_fields=get_fields,
                        render_form=render_form,
                        path=path)
Ejemplo n.º 4
0
def serve_docs(schema: APISchema, templates: Templates, path: Path):
    index = templates.get_template('apistar/docs/index.html')
    langs = ['python', 'javascript', 'shell']

    def static(path):
        return '/static/' + path

    def get_fields(link, location):
        return [
            field for field in link.fields
            if field.location == location
        ]

    return index.render(
        document=schema,
        static=static,
        langs=langs,
        get_fields=get_fields,
        render_form=render_form,
        path=path
    )
Ejemplo n.º 5
0
def get_and_render_template(username: str, templates: Templates):
    index = templates.get_template('index.html')
    return index.render(username=username)
Ejemplo n.º 6
0
def get_and_render_template(username: str, templates: Templates):
    index = templates.get_template('index.html')
    return index.render(username=username)