How to use the starlette.responses.HTMLResponse function in starlette

To help you get started, we’ve selected a few starlette examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tiangolo / fastapi / docs / src / custom_response / tutorial004.py View on Github external
def generate_html_response():
    html_content = """
    
        
            <title>Some HTML in here</title>
        
        
            <h1>Look ma! HTML!</h1>
        
    
    """
    return HTMLResponse(content=html_content, status_code=200)
github tartiflette / tartiflette-asgi / src / tartiflette_asgi / _endpoints.py View on Github external
async def get(self, request: Request) -> Response:
        config = get_graphql_config(request)
        graphql_endpoint = request["root_path"] + config.path
        subscriptions_endpoint = None
        if config.subscriptions:
            subscriptions_endpoint = request["root_path"] + config.subscriptions.path
        graphiql = config.graphiql
        assert graphiql is not None
        html = graphiql.render_template(
            graphql_endpoint=graphql_endpoint,
            subscriptions_endpoint=subscriptions_endpoint,
        )
        return HTMLResponse(html)
github mirumee / ariadne / ariadne / asgi.py View on Github external
async def render_playground(  # pylint: disable=unused-argument
        self, request: Request
    ) -> Response:
        return HTMLResponse(PLAYGROUND_HTML)
github goru001 / code-with-ai / code-with-ai / app / server.py View on Github external
def index(request):
    html = path/'view'/'index.html'
    return HTMLResponse(html.open().read())
github taoufik07 / nejma-chat / app.py View on Github external
async def get(self, request):
        return HTMLResponse(html)
github tiangolo / fastapi / fastapi / openapi / docs.py View on Github external
oauth2.errCb({
                        authId: oauth2.auth.name,
                        source: "auth",
                        level: "error",
                        message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
                    });
                }
            } else {
                oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
            }
            window.close();
        }
    
        """
    return HTMLResponse(content=html)
github apiad / auditorium / auditorium / show.py View on Github external
async def _index(self, theme: str = "white"):
        return HTMLResponse(
            self._template_dynamic.render(
                show=self,
                content=self._content,
                code_style=self._code_style(),
                theme=theme,
            )
github strawberry-graphql / strawberry / strawberry / asgi / http.py View on Github external
async def get_http_response(request: Request, execute: typing.Callable) -> Response:
    if request.method == "GET":
        html = get_playground_html(str(request.url))
        return HTMLResponse(html)

    if request.method == "POST":
        content_type = request.headers.get("Content-Type", "")

        if "application/json" in content_type:
            data = await request.json()
        else:
            return PlainTextResponse(
                "Unsupported Media Type",
                status_code=status.HTTP_415_UNSUPPORTED_MEDIA_TYPE,
            )
    else:
        return PlainTextResponse(
            "Method Not Allowed", status_code=status.HTTP_405_METHOD_NOT_ALLOWED
        )
github tiangolo / fastapi / docs / tutorial / src / all / tutorial051.py View on Github external
@app.get("/items/", content_type=HTMLResponse)
async def read_items():
    return """
github encode / starlette / starlette / graphql.py View on Github external
async def handle_graphiql(self, request: Request) -> Response:
        text = GRAPHIQL.replace("{{REQUEST_PATH}}", json.dumps(request.url.path))
        return HTMLResponse(text)