Exemple #1
0
def content():
    # global file_id
    # global up_count, down_count
    # global upvote
    # global downvote
    up_count = 0
    down_count = 0
    file_id = '1ArSB7DUAsUgxppF-Oc99n5BrztO7s-Ti'
    image_link = mongoBook.get_front(file_id)
    download_count = mongoBook.get_download(file_id)
    file_link = 'https://drive.google.com/file/d/' + file_id + '/view?usp=sharing'
    page_num = mongoBook.get_page_number(file_id)
    description = mongoBook.get_description(file_id)
    Author = mongoBook.get_author(file_id)
    upvote = mongoBook.get_upvote(file_id)
    downvote = mongoBook.get_downvote(file_id)
    title = mongoBook.get_file_name(file_id)

    return render_template("content.html", display_navbar="inline", title = title, name=first_Name, picture=profile_pic, upvote_count = upvote, downvote_count = downvote, download_count = download_count, Author = Author, file_link = file_link, image_link = image_link, page_num = page_num, description = description)
Exemple #2
0
def getfile():
    if request.method == 'GET':
        return redirect(url_for('upload'))
    elif request.method == 'POST':
        file = request.files["file"]
        file.save(os.path.join(UPLOAD_FOLDER, secure_filename(file.filename)))

        new_file = 'temp/' + secure_filename(file.filename)
        print(new_file)
        if '.pdf' in new_file:
            try:
                new_file_id = uploadFile_duplicate(
                    new_file, mongoBook.get_file_name(file_id))

                mongoBook.append_link(file_id, new_file_id)
                print("successfully uploaded")
                return render_template('upload.html', display_navbar="inline", name=first_Name, picture=profile_pic, display_upload="block", uploadNoti="Successfully uploaded to AmongUSTH")

            except Exception:
                print(Exception)
                print('Cannot upload file!')
        return render_template('upload.html', display_navbar="inline", name=first_Name, picture=profile_pic, display_upload="block", uploadNoti="Upload failed! Please try again or contact us!")