()
| 49 | |
| 50 | @app.route('/get_ad') |
| 51 | def get_ad(): |
| 52 | if banditA.sample() > banditB.sample(): |
| 53 | ad = 'A' |
| 54 | banditA.add_view() |
| 55 | else: |
| 56 | ad = 'B' |
| 57 | banditB.add_view() |
| 58 | return jsonify({'advertisement_id': ad}) |
| 59 | |
| 60 | |
| 61 | @app.route('/click_ad', methods=['POST']) |