1b6f1f91 by Glitch (hello-express)

:woman::boot: Checkpoint

./server.js:13690106/1211
./package.json:13690106/1284
1 parent e78428c9
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
10 "start": "node server.js" 10 "start": "node server.js"
11 }, 11 },
12 "dependencies": { 12 "dependencies": {
13 "express": "^4.17.1" 13 "express": "^4.17.1",
14 "gun": "^0.2020.401"
14 }, 15 },
15 "engines": { 16 "engines": {
16 "node": "12.x" 17 "node": "12.x"
......
1 // server.js 1 var Gun = require('gun');
2 // where your node app starts 2 var server = require('http').createServer().listen(3000);
3 3 var gun = Gun({web: server});
4 // we've started you off with Express (https://expressjs.com/)
5 // but feel free to use whatever libraries or frameworks you'd like through `package.json`.
6 const express = require("express");
7 const app = express();
8
9 // our default array of dreams
10 const dreams = [
11 "Find and count some sheep",
12 "Climb a really tall mountain",
13 "Wash the dishes"
14 ];
15
16 // make all the files in 'public' available
17 // https://expressjs.com/en/starter/static-files.html
18 app.use(express.static("public"));
19
20 // https://expressjs.com/en/starter/basic-routing.html
21 app.get("/", (request, response) => {
22 response.sendFile(__dirname + "/views/index.html");
23 });
24
25 // send the default array of dreams to the webpage
26 app.get("/dreams", (request, response) => {
27 // express helps us take JS objects and send them as JSON
28 response.json(dreams);
29 });
30
31 // listen for requests :)
32 const listener = app.listen(process.env.PORT, () => {
33 console.log("Your app is listening on port " + listener.address().port);
34 });
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!