From d0c6f1a5f96afec49923925c762a2c3dad585059 Mon Sep 17 00:00:00 2001 From: Julian Rother <julianr@fsmpi.rwth-aachen.de> Date: Fri, 19 Aug 2016 22:19:40 +0200 Subject: [PATCH] Parametrized play page --- server.py | 10 ++++++++-- templates/macros.html | 4 ++-- templates/play.html | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 09d51cb..1d4e93e 100755 --- a/server.py +++ b/server.py @@ -1,5 +1,5 @@ #!/bin/python -from flask import Flask, render_template, g +from flask import Flask, render_template, g, request, url_for, redirect import mysql.connector import sqlite3 import os @@ -77,7 +77,13 @@ def faq(): @app.route('/play') def play(): - return render_template('play.html', active_page='play') + if 'lectureid' in request.args: + id = request.args['lectureid'] + return render_template('play.html', + lecture=query('SELECT * FROM lectures WHERE id = ?', id)[0], + videos=query('SELECT * FROM videos WHERE lecture_id = ?', id)) + else: + return redirect(url_for(index)) if __name__ == '__main__': app.run() diff --git a/templates/macros.html b/templates/macros.html index b6852f8..2b4cc2a 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -21,10 +21,10 @@ {% endmacro %} -{% macro player() %} +{% macro player(lecture, videos) %} <script src="static/mediaelementjs/mediaelement-and-player.min.js"></script> <link rel="stylesheet" href="static/mediaelementjs/mediaelementplayer.css" /> <video class="mejs-player" width="640" height="360" style="width: 100%; height: 80%;"> - <source type="video/mp4" src="https://videoag.fsmpi.rwth-aachen.de/pub/16ss-dsal/16ss-dsal-160715-720p_1.mp4" /> + <source type="video/mp4" src="https://videoag.fsmpi.rwth-aachen.de/{{ videos[0]['path'] }}" /> </video> {% endmacro %} diff --git a/templates/play.html b/templates/play.html index 1fd881a..abb983f 100644 --- a/templates/play.html +++ b/templates/play.html @@ -2,6 +2,6 @@ {% extends "base.html" %} {% block content %} <div> - {{ player() }} + {{ player(lecture, videos) }} </div> {% endblock %} -- GitLab