-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
81 lines (48 loc) · 1.99 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const express = require('express');
const mongoose = require('mongoose');
const path = require('path');
const app = express();
app.use(express.static(path.join(__dirname, '/public')));
// first run the instance of mongodb locally then run main.js
// here fruitsDB is a database name if it does't exist it will create automatically
mongoose.connect('mongodb://localhost:27017/fruitsDB',{useNewUrlParser:true});
// this is a model example here we define our data
// u can also create schema in diff. variable
const FRUIT = mongoose.model('Fruits', { name: String });
const fruit = new FRUIT({ name: 'Apple' });
fruit.save().then(() => console.log('mongo db working'));
// if your setup is complete with mongo db
// then you will see 'mongo db working' in console
app.get("/", function (req, res) {
res.sendFile(__dirname + '/public/intro.html');
});
app.get("/explore/AI/", function (req, res) {
res.sendFile(__dirname + '/public/ai.html')
});
app.get("/explore/log_in/", function (req, res) {
res.sendFile(__dirname + '/public/log_in.html')
});
app.get("/explore/sign_up/", function (req, res) {
res.sendFile(__dirname + '/public/sign_in.html')
});
app.get("/explore/tech/", function (req, res) {
res.sendFile(__dirname + '/public/tech.html')
});
app.get("/explore/AI/pros/", function (req, res) {
res.sendFile(__dirname + '/public/ai_pros.html');
});
app.get("/explore/AI/cons/", function (req, res) {
res.sendFile(__dirname + '/public/ai_cons.html');
});
app.get("/explore/AI/real/", function (req, res) {
res.sendFile(__dirname + '/public/ai_real.html');
});
app.get("/explore/AI/real/constructive/", function (req, res) {
res.sendFile(__dirname + '/public/ai_const.html');
});
app.get("/explore/AI/real/destructive/", function (req, res) {
res.sendFile(__dirname + '/public/ai_des.html');
});
app.listen(3000, function () {
console.log("server started on port 3000");
});