-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (22 loc) · 870 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const express = require("express"); // Use this to require the express package
var app = express(); //Use this to be able to call functions within the epxress package
app.use(express.static("public"));
app.set("view engine", "ejs"); // use this to avoid having to type "home.ejs", "love.ejs", etc. Just type "home" and "love"
app.get("/", function(req, res){
res.render("home"); //Use this to render a page
});
app.get("/fellinlovewith/:thing", function (req, res){
var thing = req.params.thing
res.render("love", {thingVariable: thing});
});
app.get("/posts", function(req, res){
var posts = [
{title: "Post 1", author: "me"},
{title: "Post 2", author: "myself"},
{title: "Post 3", author: "I"}
]; //Use this object to render mulitple classes
res.render("posts", {posts: posts});
});
app.listen(3000, function() {
console.log("Server is on!");
});