> Focus on having lots of in class exercises.
> DONT teach everything, let the students investigate topics on their own aswell!
> Focus on how to read documentation, google answers and google errors!!
> Teach towards the students being able to solve the homework
Remember to add the code you wrote in the class to the relevant class branch's class work folder. If the branch has not been created just create and push it :) If you dont have access, write to one from the core team. You can see an example below!
To find examples of what teachers have taught before go to the class branches in the classwork folder, Fx class 07
If you find anything that could be improved then please create a pull request! We welcome changes, so please get involved if you have any ideas!!!
- What happens when you open a webpage - draw on a whiteboard
- Client sends http request to a url
- The request is directed to the correct ip using DNS
- The server reads the request and sends a respond
- Show a simple request and response in Chrome dev tools
- HTTP - What is the internet
- Client
- Sends request
- Receives response
- HTTP server
- Listen for requests
- Responds with data
- https://websniffer.cc/
- Client
- Introduction to node js
- What is node and why node (https://www.youtube.com/watch?v=pU9Q6oiQNd0)
- V8 vs the browser that runs js
- What can you build with nodejs?
- Utilities
- Web server
- Much more
- Simple webserver with node js
npm init- Modules
- Homemade using
module.exportsandrequire - Code inspiration
- NPM modules
- npmjs.org
npm install -s express- node_modules
- package.json
- Homemade using
- .gitignore
- Nodemon
- Play around with Express - Focus on usage!
footer.js
const getFooter = footerContent => `
<footer>
<div>
${footerContent}
</div>
</footer>
`;
module.exports = getFooter;index.js
const getFooter = require("./footer");// explain express comes from node_modules that comes from writing npm install express -s
// Take a look inside the folder!
const express = require("express");
const app = express();
app.get("/", (request, response) => {
response.send(`
<body>
<h1>Main page</h1>
<h2>Shows main content</h2>
</body>
`);
});
app.get("/about", (request, response) => {
response.send(`
<body>
<h1>About</h1>
<p>This is an about page</p>
</body>
`);
});
app.get("/contact", (request, response) => {
response.send(`
<body>
<h1>Contact</h1>
<p>This is a contact page</p>
<form>
<label>name</label>
<input placeholder="Write your name">
<button>Contact me</button>
</form>
</body>
`);
});
app.listen(3000);Start building your portfolio with these routes:
| Route | Description |
|---|---|
/ |
Add a title and sub title. Write a couple lines about yourself |
/contact |
Add social media links and your email |
/educations |
Add a list of your educations |
/skills |
Add a list of your skills |
Continuing on the last exercise. Lets add some functionality that shows the relevant title of a page using modules!
- Create a function that takes title as parameter
- Calling the function returns the html for the
headtag and thetitletag with the title tag set as the parameter - Export the function using
module.exports - Import the function using
require
Here are the routes and their corresponding title
| Route | Page title |
|---|---|
/ |
Home |
/contact |
Contact |
/educations |
Education |
/skills |
Skills |
Lets add some styling to our page. We will do it with inlining styles for now. Which should be avoided normally, but for now it is okay.
Change the previous header function to add some inline styling in the head tag.
Try and see if you can create a module with only the css as a string.
| Route | Description |
|---|---|
/projects |
Renders a list of your projects |
| Route | Page title |
|---|---|
/projects |
projects |
A project should have: title, codeUrl, previewUrl and img.
Now when the the projects route is hit, respond with some rendered html of your projects!