Recap
To emphasize that web applications form responses to requests, we first learned basic tenets of web development with Deno, while here we started to learn how to use a web framework. Web frameworks are libraries that help in creating web applications. They provide a structure for the application and often also provide tools for common tasks, such as handling requests and responses.
We learned how to create routes that map methods and paths to functions, and practiced working with request parameters. We also learned what path variables are and how to use them. With Hono, a route that responds to GET requests to the root path of the application is created as follows.
import { Hono } from "https://deno.land/x/hono@v3.12.11/mod.ts";
const app = new Hono();
app.get("/", (c) => c.text("Hello World!"));
Deno.serve(app.fetch);
Request parameters are available through the query
method of the req
attribute of the context object c
.
import { Hono } from "https://deno.land/x/hono@v3.12.11/mod.ts";
const app = new Hono();
app.get("/", (c) => c.text(`Name: ${c.req.query("name")}`));
Deno.serve(app.fetch);
Path variables are available through the param
method of the req
attribute of the context object c
.
import { Hono } from "https://deno.land/x/hono@v3.12.11/mod.ts";
const app = new Hono();
app.get("/:id", (c) => c.text(`Id: ${c.req.param("id")}`));
Deno.serve(app.fetch);
In the exercises, we separated the applications into two files, where the app.js
exported the app. We'll continue with this also in the near future.
import { Hono } from "https://deno.land/x/hono@v3.12.11/mod.ts";
const app = new Hono();
app.get("/:id", (c) => c.text(`Id: ${c.req.param("id")}`));
export default app;
In the next exercise, you use all of these jointly by creating an application that uses all of the above.
Progress estimate again
The exercise below has again the progress estimate feature that we are piloting. After you've completed the exercise, we will ask you again about the usefulness of the feature.
Once you've completed the above exercise, please provide us feedback on the progress estimate feature using the following form.
Feedback
On a scale from 1 to 7, where 1 = Strongly disagree and 7 = Strongly agree, please choose the options that best describe your opinion on the following statements.
The progress estimate functionality seemed useful to me.
The progress estimate seemed accurate to me.
The progress estimate motivated me to keep working on the problem.
I believe that the progress estimate functionality would be beneficial for my learning.
Improvement suggestions
How would you improve the progress estimate functionality?