Dion Boles

Full Stack Engineer · Healthcare & FHIR


Posts tagged #html5

Flask and Python

I’m learning how to be a full stack developer. Using Flask as a web framework and MySQL as a backend and good old HTML and jQuery as a frontend. The steps to create a website will only take a couple of minutes to make a route in flask it looks like this:

So quick start with flask:

First, you need Flask, so you can use “pip install” Flask Python 2 or
“pip3 install” Flask Python 3 and then that will install Flask in your computer. Then make a file called server.py and insert the code below:

from flask import
Flask,render_template
@app.route('/index')
def index():
 return render_template('index.html',title="data")
 if __name__ =="__main__":
 app.run(debug= True)

Your need to make an index.html and you can insert this HTML boilerplate: 

Next, just save the file, then you should go into your command line or open terminal and run python server.py or use Python3 server.py

Next copy and paste the highlighted portion of the code into your web browser and then you will get this web page!

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. 

← All posts