-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
baseurl option for working with reverse proxies #36
Comments
👍 I've been annoyed by this as well, I made a quick dirty patch to the code to support my static prefix. Spoiler: Super dirty yolo code edit:Nginx config:
Ugly code diff: python + js diff --git a/youtube_dl_webui/server.py b/youtube_dl_webui/server.py
index 62d0b3d..08a89af 100644
--- a/youtube_dl_webui/server.py
+++ b/youtube_dl_webui/server.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
@@ -8,19 +8,20 @@ from flask import render_template
from flask import request
from multiprocessing import Process
from copy import deepcopy
MSG = None
-
-app = Flask(__name__)
+URL_PREFIX="iamapig"
+app = Flask(__name__, static_url_path="{}/static".format(URL_PREFIX))
MSG_INVALID_REQUEST = {'status': 'error', 'errmsg': 'invalid request'}
-@app.route('/')
+@app.route(URL_PREFIX + '/')
def index():
return render_template('index.html')
-@app.route('/task', methods=['POST'])
+@app.route(URL_PREFIX + '/task', methods=['POST'])
def add_task():
payload = request.get_json()
@@ -28,7 +29,7 @@ def add_task():
return json.dumps(MSG.get())
-@app.route('/task/list', methods=['GET'])
+@app.route(URL_PREFIX + '/task/list', methods=['GET'])
def list_task():
payload = {}
exerpt = request.args.get('exerpt', None)
@@ -43,20 +44,20 @@ def list_task():
return json.dumps(MSG.get())
-@app.route('/task/state_counter', methods=['GET'])
+@app.route(URL_PREFIX + '/task/state_counter', methods=['GET'])
def list_state():
MSG.put('state', None)
return json.dumps(MSG.get())
-@app.route('/task/batch/<action>', methods=['POST'])
+@app.route(URL_PREFIX + '/task/batch/<action>', methods=['POST'])
def task_batch(action):
payload={'act': action, 'detail': request.get_json()}
MSG.put('batch', payload)
return json.dumps(MSG.get())
-@app.route('/task/tid/<tid>', methods=['DELETE'])
+@app.route(URL_PREFIX + '/task/tid/<tid>', methods=['DELETE'])
def delete_task(tid):
del_flag = request.args.get('del_file', False)
payload = {}
@@ -67,7 +68,7 @@ def delete_task(tid):
return json.dumps(MSG.get())
-@app.route('/task/tid/<tid>', methods=['PUT'])
+@app.route(URL_PREFIX + '/task/tid/<tid>', methods=['PUT'])
def manipulate_task(tid):
payload = {}
payload['tid'] = tid
@@ -84,7 +85,7 @@ def manipulate_task(tid):
return json.dumps(MSG.get())
-@app.route('/task/tid/<tid>/status', methods=['GET'])
+@app.route(URL_PREFIX + '/task/tid/<tid>/status', methods=['GET'])
def query_task(tid):
payload = {}
payload['tid'] = tid
@@ -99,7 +100,7 @@ def query_task(tid):
return json.dumps(MSG.get())
-@app.route('/config', methods=['GET', 'POST'])
+@app.route(URL_PREFIX + '/config', methods=['GET', 'POST'])
def get_config():
payload = {}
if request.method == 'POST':
@@ -115,7 +116,7 @@ def get_config():
###
# test cases
###
-@app.route('/test/<case>')
+@app.route(URL_PREFIX + '/test/<case>')
def test(case):
return render_template('test/{}.html'.format(case))
@@ -134,4 +135,3 @@ class Server(Process):
MSG = self.msg_cli
app.run(host=self.host, port=int(self.port), use_reloader=False)
-
diff --git a/youtube_dl_webui/static/js/global.js b/youtube_dl_webui/static/js/global.js
index 7d5935b..4f6e329 100644
--- a/youtube_dl_webui/static/js/global.js
+++ b/youtube_dl_webui/static/js/global.js
@@ -3,7 +3,7 @@ var videoDownload = (function (Vue, extendAM){
var VueToast = window.vueToasts ? window.vueToasts.default || window.vueToasts : window.vueToasts;
videoDownload.vm = null;
videoDownload.tasksData = {
- headPath: 'http://localhost:5000/',
+ headPath: '/iamapig/',
videoList: [],
videoListCopy: [],
showModal: false,
@@ -293,7 +293,7 @@ var videoDownload = (function (Vue, extendAM){
videoDownload.init = function(){
var that = this;
- that.tasksData.headPath = window.location.protocol + '//' + window.location.host + '/';
+ that.tasksData.headPath = window.location.protocol + '//' + window.location.host + '/iamapig/';
that.createVm();
that.getTaskList();
}
|
Hi, I'm in the same situation. Can you please make a PR of your changes? Thanks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any thoughts on adding an option to change the baseurl? I ask because it'd be cool if this could work with reverse proxies like nginx
The text was updated successfully, but these errors were encountered: