This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
var fs = require("fs"); | |
var server = http.createServer().listen(3000); | |
server.on("request", function(req, res) { | |
if (req.method != "POST") return res.end(); | |
var imageName = "received-" + Date.now() + ".jpg"; | |
var writeStream = fs.createWriteStream(imageName); | |
req.pipe(writeStream); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// including the net module | |
const net = require('net'); | |
// clients array | |
let clients = []; | |
// a nice little logger with a time stamp | |
// loggin messages for both server and Client | |
function logger(m){ | |
let d = new Date().toLocaleString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple BlockChain example via Nodejs | |
// this example shows the core functionality of a BlockChain system and how it works | |
// want to add more options? here's the GitHub rep: https://github.com/AliSawari/SimpleBlockChain | |
// THIS EXAMPLE IS INSPIRED BY : youtu.be/zVqczFZr124 | |
// requiring Hash function | |
const {createHmac} = require('crypto'); | |
// simplify some functions | |
function str(val){ |
NewerOlder