initial version capable of receiving POST data from Particle Core
This commit is contained in:
		
						commit
						0491df321d
					
				
							
								
								
									
										2
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								Dockerfile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| FROM node:0.12.4-onbuild | ||||
| EXPOSE 3000 | ||||
							
								
								
									
										8
									
								
								index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								index.html
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| <html !DOCTYPE=html> | ||||
| <head> | ||||
| 
 | ||||
| </head> | ||||
| <body> | ||||
|     <h1>Test page for Alert Monitor app:</h1> | ||||
| </body> | ||||
| </html> | ||||
							
								
								
									
										9
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,9 @@ | ||||
| { | ||||
|     "name": "alertmon", | ||||
|     "version": "0.0.1", | ||||
|     "dependencies": { | ||||
|         "body-parser": "^1.12.4", | ||||
|         "express": "^4.12.4" | ||||
|     }, | ||||
|     "scripts": { "start": "node server.js" } | ||||
| } | ||||
							
								
								
									
										25
									
								
								server.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								server.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| var express = require("express"); | ||||
| var fs = require("fs"); | ||||
| var bodyParser = require("body-parser"); | ||||
| var app = express(); | ||||
| var logfile = fs.createWriteStream('./log.log', {flags: 'a'}); | ||||
| 
 | ||||
| app.use(bodyParser.json()); | ||||
| 
 | ||||
| app.get('/', function(req, res){ | ||||
|     //res.sendFile("/usr/src/app/index.html");
 | ||||
|     fs.createReadStream('./log.log').pipe(res); | ||||
|     console.log("got a GET request..."); | ||||
| }); | ||||
| 
 | ||||
| app.post('/', function(req, res){ | ||||
|     var postEvent = req.body.postEvent; | ||||
|     var source = req.body.source; | ||||
|     console.log("Post event = "+postEvent+", source is "+source); | ||||
|     console.log(req.body); | ||||
|     //res.send(JSON.stringify(req.body, null, 4));
 | ||||
| }); | ||||
| 
 | ||||
| app.listen(3000, function() { | ||||
|     console.log("Started on PORT 3000"); | ||||
| }) | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user