youtube-dl-fe/app/main.py

35 lines
736 B
Python
Raw Normal View History

2020-09-21 18:40:41 +01:00
from flask import Flask, render_template as Render
2020-08-27 14:02:19 +01:00
from flask_rq2 import RQ as _RQ
2020-09-21 18:40:41 +01:00
import rq_dashboard as _RQD
2020-08-27 14:02:19 +01:00
from youtube_dl import YoutubeDL as YDL
from time import sleep
from .log import FeLog
from .callbacks import CbJob
BaseYDLOpts={
'no_color': True,
'call_home': False,
'logger': FeLog(),
'progress_hooks': {
'status': CbJob.status,
},
}
2020-08-26 18:24:41 +01:00
2020-09-21 18:40:41 +01:00
# Init
2020-08-26 18:24:41 +01:00
app=Flask(__name__)
2020-09-21 18:40:41 +01:00
app.config.from_object(_RQD.default_settings)
app.register_blueprint(_RQD.blueprint, url_prefix="/redis")
2020-08-27 14:02:19 +01:00
RQ=_RQ(app)
2020-09-21 18:40:41 +01:00
#Routes
2020-08-27 14:02:19 +01:00
@RQ.job('test', timeout=30)
def DeliberatelyTimesOut():
sleep(35)
2020-08-26 18:24:41 +01:00
2020-08-27 14:02:19 +01:00
@app.route('/')
2020-09-21 18:40:41 +01:00
def index(): return Render("index.html.j2")
2020-08-26 18:24:41 +01:00
2020-08-27 14:02:19 +01:00
@app.route('/add/timeouttest')
def timeouttest():
j=DeliberatelyTimesOut.queue()
return 'queued'