from flask import Flask, render_template import random app = Flask(__name__) @app.route('/') def index(): coin = random.random() if coin >= 0.5: return render_template('index.html') else: raise Exception("Bad luck") if __name__ == '__main__': app.run(debug=False)