def apiServiceDownload(id=None): return_value = "{'status':'error','message':'login is required'}"; if 'username' in session and request.is_xhr: doc = db_video.get(id) newThread = threading.Thread(target=download_video, args=(doc,)) threadList.append(newThread) newThread.start() doc_return = {'status':'ok','message':'video will be downloaded','result':''} return_value = jsonify(doc_return) elif not(request.is_xhr): return_value = redirect(url_for('login')) return return_value
def addVideo(): return_value = redirect(url_for('login')) if 'username' in session: form = DownloadVideoForm() if request.method == 'POST' and form.validate(): return_value = redirect('/') try: doc = db_queue.add_url(form.videoURL.data) newThread = threading.Thread(target=download_video_info, args=(doc,)) threadList.append(newThread) newThread.start() except: print 'error in do_addURL' else: return_value = render_template('video.html', form=form,username=session['username']) return return_value