-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (27 loc) · 692 Bytes
/
server.js
File metadata and controls
28 lines (27 loc) · 692 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
var express = require('express')
var admin = require("firebase-admin");
var app = express()
var serviceAccount = require("./fire-bb43b-firebase-adminsdk-oegpb-0bff76fe92.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://fire-bb43b.firebaseio.com"
});
var db = admin.database()
var iot=db.ref('iot')
app.get('/', function (req, res) {
iot.push().set({
value:req.query.value
})
res.json({
value:req.query.value
})
})
app.get('/clear',function(req,res){
iot.set(null)
res.json({
success:true
})
})
app.listen(8080, function () {
console.log('App listening on port 8080!')
})