Skip to content

Commit

Permalink
Modified home page UI
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwaspuri committed May 7, 2021
1 parent 8111368 commit 52da5bc
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*__pycache__
.vscode
.idea
Binary file removed __pycache__/filter.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/main.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/main_cross_sell.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/main_up_sell.cpython-37.pyc
Binary file not shown.
Binary file removed __pycache__/quantity.cpython-37.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ def main_recommend(user_id, user_product, user_qty):
common3 = [(user_qty, i) for i in common3]
new3 = [(user_qty, i) for i in new3]


return [new1, new2, new3, common1, common2, common3]
6 changes: 3 additions & 3 deletions main_flask.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from flask import Flask, redirect, url_for, request, render_template
from main import *

app = Flask(__name__, template_folder='template')
app = Flask(__name__, template_folder='template', static_folder='static', static_url_path='')

@app.route('/success/<user_id>/<user_product>/<user_qty>',methods = ['GET'])
def success(user_id, user_product, user_qty):
ret=main_recommend(int(user_id), int(user_product), float(user_qty))
return render_template('results.html', res=ret)

@app.route('/login',methods = ['POST', 'GET'])
@app.route('/',methods = ['POST', 'GET'])
def login():
if request.method == 'POST':
user_id = request.form['nm']
user_product= request.form['pr']
user_qty = request.form['qty']
return redirect(url_for('success',user_id = user_id, user_product=user_product, user_qty=user_qty))
else:
return render_template('login.html')
return render_template('index.html')

if __name__ == '__main__':
app.run(debug = True)
88 changes: 88 additions & 0 deletions static/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
.product{
position: relative;
top: 30vh;
left: 10vw;
width: 20vw;
padding-left: 3vw;
}


body {
background: linear-gradient(-45deg, #23a6d5, #23d5ab);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
}

@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

input[type=text]{
width: 300px;
/* padding: 10px 20px; */
padding-top: 5px;
padding-bottom: 10px;
border-color: transparent;
border-bottom: 1px solid whitesmoke;
font-size: 15px;
background: transparent;
}

input:focus{
outline: none;
}

input::-webkit-input-placeholder {
padding-left: 5px;
font-size: 15px;
color: whitesmoke;
}

input:-moz-placeholder { /* Firefox 18- */
padding-left: 5px;
font-size: 15px;
color: whitesmoke;
}

input::-moz-placeholder { /* Firefox 19+ */
padding-left: 5px;
font-size: 15px;
color: whitesmoke;
}

input:-ms-input-placeholder {
padding-left: 5px;
font-size: 15px;
color: whitesmoke;
}

label{
font-size: 20px;
/* color: rgb(82, 71, 71); */
color: rgb(99, 93, 93);
padding-top: 5px;
}
input[type=submit] {
cursor: pointer;
border: 1px solid white;
background-color: transparent;
height: 50px;
width: 200px;
color: white;
font-size: 17px;
/* box-shadow: 0 6px 6px rgba(0, 0, 0, 0.6); */
}

.form-label{
font-size: 25px;
color: rgb(99, 93, 93);
font-weight: bold;
}
25 changes: 25 additions & 0 deletions template/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>

<head>
<link rel="stylesheet" href="index.css">
</head>

<body>
<div class="product">
<p class="form-label">Select a product:</p>
<form action="http://localhost:5000/" method="post" >
<label for="nm">User ID:</label>
<input type="text" name="nm" id="nm" /><br><br>
<label for="pr">Product:</label>
<input type="text" name="pr" id="pr" /><br><br>
<label for="qty">Quantity:</label>
<input type="text" name="qty" id="qty" /><br><br>
<input type="submit" value="Provide reccomendation" class="btn" />
</form>
</div>
<div id="result">

</div>
</body>

</html>
13 changes: 0 additions & 13 deletions template/login.html

This file was deleted.

21 changes: 12 additions & 9 deletions template/results.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<html>
<body>
<p>New recommendations based on users using similar product: {{res[0]}}<br>
New recommendations based on users in similar location and groupements: {{res[1]}}<br>
New recommendations based on similar products: {{res[2]}}<br>
Previously ordered products recommendations based on users using similar product: {{res[3]}}<br>
Previously ordered products recommendations based on users in similar location and groupements: {{res[4]}}<br>
Previously ordered products recommendations based on similar products: {{res[5]}}<br>
</p>
</body>

<body>
<p>
New recommendations based on users using similar product: {{res[0]}}<br>
New recommendations based on users in similar location and groupements: {{res[1]}}<br>
New recommendations based on similar products: {{res[2]}}<br>
Previously ordered products recommendations based on users using similar product: {{res[3]}}<br>
Previously ordered products recommendations based on users in similar location and groupements: {{res[4]}}<br>
Previously ordered products recommendations based on similar products: {{res[5]}}<br>
</p>
</body>

</html>

0 comments on commit 52da5bc

Please sign in to comment.