-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
98 lines (79 loc) · 2.77 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from flask import Flask, render_template, Response,redirect,request
from camera import VideoCamera
from werkzeug.utils import secure_filename
import os
import time
import sys
from PIL import Image
sys.modules['Image'] = Image
app = Flask(__name__)
APP_ROOT= os.path.dirname(os.path.abspath(__file__))
target = os.path.join(APP_ROOT,'static/')
app.config["DEBUG"] = True
picFolder = os.path.join('static/assets/images','User-Image')
#os.path.isfile('mydirectory/myfile.txt') ---> to check whether file existe or not
app.config["UPLOAD_FOLDER"] = picFolder
pic1 = os.path.join(app.config['UPLOAD_FOLDER'],'HERO.jpg')
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
st=""
CART=[]
@app.route('/')
def index():
return render_template('index.html')
@app.route('/chatbot')
def chatbot():
return render_template("chatbot.html")
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/upload',methods=["GET","POST"])
def upload():
if request.method == "POST":
file=request.files['uploadBills']
#file.save(secure_filename(file.filename))
#file.save(os.path.join("static/pics", file.filename))
#some custom file name that you want
if file and allowed_file(file.filename):
st=allowed_file(file.filename)
file.filename="8.png"
file.save("static/assets/images/Frocks5/"+file.filename)
time.sleep(1)
return render_template('Home.html')
return render_template('upload.html')
def allowed_file(filename):
return filename.rsplit('.', 1)[1].lower()
@app.route('/team')
def team():
return render_template('team.html')
@app.route('/Home')
def Home():
return render_template('Home.html')
@app.route('/tryon/<file_path>',methods = ['POST', 'GET'])
def tryon(file_path):
file_path = file_path.replace(',','/')
os.system('python tryOn.py ' + file_path)
return redirect('http://127.0.0.1:5000/',code=302, Response=None)
@app.route('/tryall',methods = ['POST', 'GET'])
def tryall():
if request.method == 'POST':
cart = request.form['mydata'].replace(',', '/')
os.system('python test.py ' + cart)
render_template('checkout.html', message='')
def gen(camera):
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
@app.route("/cart/<file_path>",methods = ['POST', 'GET'])
def cart(file_path):
global CART
file_path = file_path.replace(',','/')
print("ADDED", file_path)
CART.append(file_path)
return render_template("checkout.html")
@app.route('/video_feed')
def video_feed():
return Response(gen(VideoCamera()),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run()