Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"type": "http.response.body",
"body": b"<h1>Hello, world!</h1>",
}
)
return asgi
mock_request = MockHttpRequest(
"GET",
"/",
headers={"content-type": "text/html; charset=utf-8"},
params={"name": "val"},
route_params=None,
body=None,
)
handler = AzureFunctionAdapter(app)
response = handler(mock_request)
assert response.status_code == 200
assert response.get_body() == b"<h1>Hello, world!</h1>"
assert response.charset == "utf-8"
assert response.mimetype == "text/html"
app = Starlette()
@app.route("/")
def homepage(request):
return HTMLResponse("<h1>Hello, world!</h1>")
mock_request = MockHttpRequest(
"GET",
"/",
headers={"content-type": "text/html; charset=utf-8"},
params=None,
route_params=None,
body=None,
)
handler = AzureFunctionAdapter(app)
response = handler(mock_request)
assert response.status_code == 200
assert response.get_body() == b"<h1>Hello, world!</h1>"
assert response.charset == "utf-8"
assert response.mimetype == "text/html"
mock_request = MockHttpRequest(
"GET",
"/",
headers={"content-type": "text/html; charset=utf-8"},
params=None,
route_params=None,
body=None,
)
app = Quart(__name__)
@app.route("/")
async def hello():
return "<h1>Hello, world!</h1>"
handler = AzureFunctionAdapter(app)
response = handler(mock_request)
assert response.status_code == 200
assert response.get_body() == b"<h1>Hello, world!</h1>"
assert response.charset == "utf-8"
assert response.mimetype == "text/html"
)
await send({"type": "http.response.body", "body": body})
return asgi
body = b"123"
mock_request = MockHttpRequest(
"POST",
"/",
headers={"content-type": "text/html; charset=utf-8"},
params=None,
route_params=None,
body=body,
)
handler = AzureFunctionAdapter(app)
response = handler(mock_request)
assert response.status_code == 200
assert response.get_body() == b"123"
assert response.charset == "utf-8"
assert response.mimetype == "text/html"