H

 

pip install flask flask-cors from flask import Flask, jsonify, request import random app = Flask(__name__) # Colors list COLORS = ["Red", "Green", "Blue"] # Route to predict color @app.route('/predict', methods=['POST']) def predict_color(): user_prediction = request.json.get('prediction') bet_amount = request.json.get('amount') # Generate random color actual_color = random.choice(COLORS) result = "Lose" # Check if the user won or lost if user_prediction == actual_color: result = "Win" winnings = bet_amount * 2 # Double the amount if user wins else: winnings = 0 return jsonify({ "actual_color": actual_color, "result": result, "winnings": winnings }) if __name__ == "__main__": app.run(debug=True) Color Prediction App

Color Prediction Game





python app.py

Post a Comment

0 Comments