-
Notifications
You must be signed in to change notification settings - Fork 310
/
server.js
49 lines (38 loc) · 1 KB
/
server.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// require express and other modules
var express = require('express'),
app = express();
// serve static files from public folder
app.use(express.static(__dirname + '/public'));
/************
* DATABASE *
************/
// your hardcoded data here
/**********
* ROUTES *
**********/
/*
* HTML Endpoints
*/
app.get('/', function homepage (req, res) {
res.sendFile(__dirname + '/views/index.html');
});
/*
* JSON API Endpoints
*/
app.get('/api', function api_index (req, res){
res.json({
message: "Welcome to my personal api!",
documentation_url: "https://github.com/sf-wdi-25/express_self_api/README.md", // CHANGE THIS TO LINK TO YOUR README.md
base_url: "http://YOUR-APP-NAME.herokuapp.com",
endpoints: [
{method: "GET", path: "/api", description: "Describes available endpoints"}
]
})
});
/**********
* SERVER *
**********/
// listen on port 3000
app.listen(process.env.PORT || 3000, function () {
console.log('Express server is running on http://localhost:3000/');
});