예제 #1
0
def upload():
    if request.method == 'POST':
        # check if the post request has the file part
        if 'file' not in request.files:
            print("No file part")
            flash('No file part')
            return redirect(request.url)
        file = request.files['file']
        # if user does not select file, browser also
        # submit an empty part without filename
        if file.filename == '':
            flash('No selected file')
            return redirect(request.url)
        if file:
            print(os.getcwd())
            filename = secure_filename(file.filename)
            print("User %s uploaded file %s" %
                  (current_user.get_id(), filename))
            if (not ospathexists(UPLOAD_FOLDER + str(current_user.get_id()))):
                print("Making dir %s" %
                      (str(UPLOAD_FOLDER + str(current_user.get_id()))))
                mkdir(UPLOAD_FOLDER + str(current_user.get_id()), 0o755)
            file.save(
                ospathjoin(UPLOAD_FOLDER + str(current_user.get_id()),
                           filename))

            add_video(
                current_user.get_id(),
                ospathjoin(UPLOAD_FOLDER + str(current_user.get_id()),
                           filename), filename, "Lorem Ipsum")
            return redirect('/')
    username = None
    if current_user.is_authenticated:
        username = current_user.get_uname()
    return render_template('upload.html', user=username)
예제 #2
0
def watch(id):
    print(id)
    video = db.get_video(int(id))
    vid = {}
    vid['title'] = video.title
    vid['content'] = "/" + "/".join(video.content.split('/')[3:])
    vid['id'] = video.id
    vid['owner'] = video.owner
    vid['description'] = video.description
    print("Video title %s is at %s" % (video.title, video.content))
    username = None
    if current_user.is_authenticated:
        username = current_user.get_uname()
    return render_template('watch.html', vid=vid, user=username)
예제 #3
0
def sqli_blank():
    username = None
    if current_user.is_authenticated:
        username = current_user.get_uname()
    vids = db.get_all_videos()
    return render_template('index.html', user=username, videos=vids)
예제 #4
0
def search2(term):
    username = None
    if current_user.is_authenticated:
        username = current_user.get_uname()
    vids = db.search_video2(term)
    return render_template('index.html', user=username, videos=vids)
예제 #5
0
def profile():
    print("Profile is authed? %s" % (str(current_user.is_authenticated)))
    print(current_user.get_uname())
    return render_template('profile.html', name=current_user.get_uname())