Skip to content

Commit

Permalink
Update main_flask.py
Browse files Browse the repository at this point in the history
  • Loading branch information
manitbaser authored May 9, 2021
1 parent 9bd4e4c commit bcf9564
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def isint(value):
data1 = list(pd.read_csv('./blacklisted_wholesaler_product.csv')['wholesaler id'])
data2 = list(pd.read_csv('./blacklisted_product_product.csv')['product id'])

prod_info = pd.read_csv('./products_info.csv', index_col="id")
user_info = pd.read_csv('./wholesalers_info.csv', index_col="id")

@app.route('/success/<user_id>/<user_product>/<user_qty>/',methods = ['GET', 'POST'])
def success(user_id, user_product, user_qty):
if request.method =='POST':
Expand Down Expand Up @@ -55,6 +58,7 @@ def login():
user_id = request.form['nm']
user_product= request.form['pr']
user_qty = request.form['qty']

# Error Handling

if user_id=='' or isint(user_id)==False or int(user_id) not in (data1):
Expand All @@ -65,6 +69,10 @@ def login():
return render_template('index.html', flash_message="Invalid Quantity provided")
if (float(user_qty)<0):
return render_template('index.html', flash_message="Invalid Quantity provided")
if int(user_id) not in list(user_info.index):
return render_template('index.html', flash_message="Enter User ID details in the database ")
if int(user_product) not in list(prod_info.index):
return render_template('index.html', flash_message="Enter Product ID details in the database such as brand etc. ")
return redirect(url_for('success',user_id = user_id, user_product=user_product, user_qty=user_qty))
else:
return render_template('index.html')
Expand All @@ -75,4 +83,4 @@ def login():
# return render_template("blacklist_p2p.html", data=x)

if __name__ == '__main__':
app.run(debug = True)
app.run(debug = True)

0 comments on commit bcf9564

Please sign in to comment.