Dion Boles

Full Stack Engineer · Healthcare & FHIR


Posts tagged #coding

I think i still like php :) but node js fun.

I have recently made a youtube tutorial that is base on how to stream video with node js but i just recently recoded in php and it was shorter to code in php like ok so here is the node js code. I will post the code below.    


Node JS Code 

var http = require(“http”);
var fs = require(“fs”);

console.log(“Server starting at localhost 3000”);
http.createServer(function (request,response) {
response.writeHead(200,{‘Content-Type’: 'video/mp4’});
var rs = fs.createReadStream(“cat.mp4”);
rs.pipe(response);
}).listen(3000);

and here is the php code 

Php Code and Html 5 

$files = “cat.mp4”;
$size = filesize($files);
header(“Content-Type: video/mp4”);
header(“Content-Length:”.$size);
readfile($files);

<!DOCTYPE html>
<html>
<head>
<meta charset=“UTF-8”>
<title>video stream</title>
</head>
<body>
<h1> video </h1>
<video src=“video.php” type=“video/mp4” controls></video>
</body>
</html>

This was the php code was more reuseable i could stream a file into a html video tag but i’m not that experienced in node js or php i just dabble with both. i feel like php is great and node js is the future of web dev but maybe php is still more useful. 

Node js and me

The Journey to learn Node js is a hard one for me because of the millions of frameworks that are on npm. I want to learn how to code with node js because of the speed benefits. But Learning to use a framework like express then ejs or jade i want to learn the basics so maybe I can make my own. I have to learn so much now just to keep up. I’m going to learn it all but I just found php to be easier then node js but maybe I just need to sit down and really make something like a blog engine that sounds fun. I just wanted to talk about my journey with node js. It sounds like a first world developer problem.

← All posts