Untitled

mail@pastecode.io avatar
unknown
python
a year ago
741 B
1
Indexable
Never
from flask import Flask, render_template, request

app = Flask(__name__)

@app.route('/')
def index():
  return render_template('index.html')

@app.route('/products')
def products():
  products = [
    {'name': 'Baseball', 'price': 9.99},
    {'name': 'Basketball', 'price': 19.99},
    {'name': 'Football', 'price': 29.99},
    {'name': 'Tennis Racquet', 'price': 149.99},
  ]
  return render_template('products.html', products=products)

@app.route('/buy', methods=['POST'])
def buy():
  name = request.form['name']
  price = request.form['price']
  quantity = request.form['quantity']

  # Add code here to process the order and charge the user
  # ...

  return render_template('success.html', name=name, price=price, quantity=quantity)