How to server all the mp4 files in a folder

from flask import Flask
from os import listdir
from os.path import isfile, join

def get_folder_files(folder):
    return [f for f in listdir(folder) if isfile(join(folder, f)) and f != '']

def gen_mp4_block(file_name):
    return '''
    <video width="720" controls>
        <source src="./static/{0}" type="video/mp4">

def merge_mp4_blocks(file_names):
    html = ''
    for file in file_names:
        html = html + gen_mp4_block(file)
    return html

app = Flask(__name__)

def index():
    html = '''
        <!doctype html>
                <title>Serve all Files</title>
                <h1>Serve all Files</h1>
    return html

if __name__ == '__main__':'', port=80)

Folder Structure

project root folder
|- static
    |- video1.mp4
    |- video2.mp4
    |- ......


The following Python packages are used:

  • flask
  • os