forked from hackclub/guide-referral
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 919 Bytes
/
index.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
var express = require("express");
const bodyParser = require('body-parser');
var app = express();
var Airtable = require('airtable');
require('dotenv').config();
app.use(bodyParser.urlencoded({ extended: true }));
var base = new Airtable({apiKey: process.env.AIRTABLE_KEY}).base(process.env.AIRTABLE_BASE);
app.listen(process.env.PORT || 3000, () => {
console.log("The potato is running on port 3000");
});
app.post('/chopchop',function(req,res){
var username=req.body.username;
var source=req.body.source;
var page=req.body.page;
base('Auto Grant').create({
"User": username,
"Submitted": source,
"Page Name": page
}, function(err, record) {
if (err) {
console.error(err);
return;
}
console.log("Success! Record ID: " + record.getId());
});
res.json({ success: true });
});
app.use(express.static('public'))