Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import random
- from flask import Flask, send_file # Make sure you have Flask enabled
- app = Flask(__name__)
- @app.route('/')
- def random_image():
- folder_path = 'C:\\Folder\\ImageFolder' # Update this with your folder path, change it for Linux to Linux folder structure - e.g., /home/your_username/Images
- images = os.listdir(folder_path)
- random_image = random.choice(images)
- return send_file(os.path.join(folder_path, random_image))
- if __name__ == '__main__':
- app.run(host='0.0.0.0', port=5000) # Change port to whatever you want
Advertisement
Add Comment
Please, Sign In to add comment