-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.js
31 lines (26 loc) · 957 Bytes
/
app.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
const fs = require('fs');
const auth = require('./authorize');
const services = require('./services');
const express = require('express');
const app = express();
const port = 3000;
app.use(express.static('./public'));
app.get('/prov', (req, res) => {
// Load client secrets from a local file.
fs.readFile('credentials.json', (err, content) => {
if (err) return console.log('Error loading client secret file:', err);
// Authorize a client with credentials.
auth.authorize(JSON.parse(content), services.getTests, res);
});
});
app.get('/uppgifter', (req, res) => {
// Load client secrets from a local file.
fs.readFile('credentials.json', (err, content) => {
if (err) return console.log('Error loading client secret file:', err);
// Authorize a client with credentials.
auth.authorize(JSON.parse(content), services.getAssignments, res);
});
});
app.listen(port, () => {
console.log(`Listening on port ${port}!`);
});