Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/')
- def dir_listing(file_Idx=0):
- # Return 404 if path doesn't exist
- if not os.path.exists(DOWNLOAD_FOLDER):
- print("PATH IS NONEXISTENCT!!!!")
- return abort(404)
- # Show directory contents
- files = os.listdir(DOWNLOAD_FOLDER)
- filePath = os.path.join(DOWNLOAD_FOLDER, files[file_Idx])
- return render_template('files.html', file=filePath, file_Idx=file_Idx)
- @app.route('/', methods=['GET', 'POST'])
- def upload_file(file_Idx=0, label1 = 'someLabel', label2 = 'someLabel2'):
- print(request.files) #returns as empty dict
- if request.method == 'POST' or request.method == 'GET':
- if 'file' not in request.files:
- #Jumps in here every time
- return redirect(request.url)
- #... to be implemented to move file to correct location
- return redirect(url_for('dir_listing', file_Idx=file_Idx))
- <body>
- <form method=post>
- <img id=fileId type=file name=file width="200" height="200" src="{{ file }}"/>
- <input type=submit value=Upload>
- </form>
- </body>
Add Comment
Please, Sign In to add comment