From 16196222572a4ad77e1ef48dc0bc78e633eb0545 Mon Sep 17 00:00:00 2001 From: Bui Date: Mon, 12 Nov 2018 11:34:49 +0000 Subject: [PATCH] use urlparse for preview url joining --- app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 48db087..bec341c 100644 --- a/app.py +++ b/app.py @@ -6,6 +6,7 @@ import json import sqlite3 import re import os +import urlparse from flask import Flask, g, jsonify, render_template, request, abort, redirect from ffmpy import FFmpeg @@ -145,9 +146,9 @@ def route_api_preview(): song_type = song_row[0][10] prev_path = make_preview(song_id, song_type) if not prev_path: - return redirect(''.join([request.host_url, '/songs/%s/main.mp3' % song_id])) + return redirect(urlparse.urljoin(request.host_url, '/songs/%s/main.mp3' % song_id)) - return redirect(''.join([request.host_url, '/songs/%s/preview.mp3' % song_id])) + return redirect(urlparse.urljoin(request.host_url, '/songs/%s/preview.mp3' % song_id)) @app.route('/api/songs')