Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Bookshop_5001CEM/shopping_cart.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
28 lines (24 sloc)
1.5 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from main import app | |
from flask import Flask,redirect,url_for,render_template,abort,request,abort,make_response,session,g,flash | |
import sqlite3 | |
from werkzeug.utils import secure_filename | |
import os | |
@app.route('/shopping_cart', methods = ['GET','POST']) | |
def shopping_cart(): | |
if request.method == 'POST': | |
if request.form['Submit'] == 'GO TO HOME': #when the GO TO HOME button is pressed redirect to the homepage | |
return redirect(url_for('homepage')) | |
elif request.form['Submit'] == 'CANCEL' or request.form['Submit'] == 'PAY NOW': | |
#we want to clear everything from a session except logged_in, so we store it inside a variable, in order to add it after clearing it | |
remember = session['logged_in'] | |
session.clear() | |
session['logged_in'] = remember | |
return redirect(url_for('homepage')) | |
elif request.form['Submit'] == 'ADD STOCK': #when the ADD STOCK is pressed redirect to the the add book form | |
return redirect(url_for('add_stock')) | |
elif request.form['Submit'] == 'GO TO CART': #when the GO TO CART button is pressed redirect to the shopping cart | |
return render_template('shopping_cart.html') | |
elif request.form['Submit'] == 'CHECKOUT': #when the CHECKOUT button is pressed redirect to the checkout | |
return render_template('checkout.html') | |
else: | |
return render_template('shopping_cart.html') | |