Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
async def render_playground( # pylint: disable=unused-argument
self, request: Request
) -> Response:
return HTMLResponse(PLAYGROUND_HTML)
def index(request):
html = path/'view'/'index.html'
return HTMLResponse(html.open().read())
async def get(self, request):
return HTMLResponse(html)
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)
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,
)
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
)
@app.get("/items/", content_type=HTMLResponse)
async def read_items():
return """
async def handle_graphiql(self, request: Request) -> Response:
text = GRAPHIQL.replace("{{REQUEST_PATH}}", json.dumps(request.url.path))
return HTMLResponse(text)