-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
78 lines (61 loc) · 2.31 KB
/
server.js
File metadata and controls
78 lines (61 loc) · 2.31 KB
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
// *****************************************************************************
// Server.js - This file is the initial starting point for the Node/Express server.
//
// ******************************************************************************
// *** Dependencies
// =============================================================
var bodyParser = require("body-parser");
// const upload = multer({
// dest: 'uploads/' // this saves your file into a directory called "uploads"
// });
const express = require('express');
const multer = require('multer');
const upload = multer({
dest: 'public/uploads/' // this saves your file into a directory called "uploads"
});
const app = express();
app.get('/', (req, res) => {
res.sendFile(__dirname + '/public/cms.html');
});
// It's very crucial that the file name matches the name attribute in your html
app.post('/public', upload.single('fileUpload'), (req, res) => {
res.redirect('/');
});
// app.get('/', (req, res) => {
// res.sendFile(__dirname + '/public/cms.html');
// });
// // It's very crucial that the file name matches the name attribute in your html
// app.post('/', upload.single('file-to-upload'), (req, res) => {
// res.redirect('/blog.html');
// });
// $(document).ready(function () {
// var addressPicker = new AddressPicker();
// $('#zip_code').typeahead(null, {
// displayKey: 'description',
// source: addressPicker.ttAdapter()
// });
// console.log("ready!");
// });
// Sets up the Express App
// =============================================================
var PORT = process.env.PORT || 8080;
// Requiring our models for syncing
var db = require("./models");
// Sets up the Express app to handle data parsing
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }));
// parse application/json
app.use(bodyParser.json());
// Static directory
app.use(express.static("public"));
// Routes
// =============================================================
require("./routes/api-routes.js")(app);
require("./routes/html-routes.js")(app);
// Syncing our sequelize models and then starting our Express app
// =============================================================
db.sequelize.sync({ force: false }).then(function() {
app.listen(PORT, function() {
console.log("App listening on PORT " + PORT);
});
});