-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (24 loc) · 761 Bytes
/
index.js
File metadata and controls
30 lines (24 loc) · 761 Bytes
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
const express = require('express');
const app = express();
require('dotenv').config();
//const app = require("express")();
app.use(express.json());
const fs = require("fs");
app.use("/js", express.static("./public/js"));
app.use("/img", express.static("./public/images"));
app.use("/css", express.static("./public/css"));
app.get('/api-key', (req, res) => {
// send API key to the frontend
const API_KEY = process.env.GOOGLE_PLACES_API;
res.send({ apiKey: API_KEY });
});
app.get("/", function (req, res) {
let doc = fs.readFileSync("./public/index.html", "utf8");
// just send the text stream
res.send(doc);
});
// RUN SERVER
let port = 8000;
app.listen(port, function () {
console.log("App listening at " + port + "!");
});