Deno.serve used for in Deno?Deno.serve is a simple way to create an HTTP server that listens for requests and sends responses.
Deno.serve?You provide a function to Deno.serve that takes a Request object and returns a Response object.
await Deno.serve(req => new Response('Hello'))This code starts an HTTP server that responds with 'Hello' to every request it receives.
Deno.serve handle asynchronous operations inside the request handler?Yes, the request handler function can be async, allowing you to await operations like database calls before sending a response.
Deno.serve?You pass an options object as the first argument with a port property, like Deno.serve({ port: 8080 }, handler).
Deno.serve receive?The function receives a Request object representing the incoming HTTP request.
Deno.serve?You return a new Response object with the text as its body.
The port is set by passing an options object with a port property as the first argument.
Deno.serve?The handler can be async to handle asynchronous tasks before responding.
Deno.serve?If no port is specified, Deno.serve uses port 8000 by default.
Deno.serve that responds with 'Welcome!' to every request.Deno.serve request handler.