-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
105 lines (84 loc) · 14.8 KB
/
app.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
99
100
101
102
103
104
from flask import Flask, render_template, request
from flask_bootstrap import Bootstrap
from flask_pymongo import PyMongo
from ebay import getmpn, getbrandmodel
from ebayApi import ebayAPI
from mercari import get_items
import datetime
import math
app = Flask(__name__)
Bootstrap(app)
app.config['MONGO_URI'] = "mongodb+srv://alan:[email protected]/test?retryWrites=true&w=majority"
mongo = PyMongo(app)
test = {
"image":"https://mercari-images.global.ssl.fastly.net/photos/m86893773555_1.jpg?1579372204&w=200&h=200&fitcrop&sharpen",
"price" : "25",
"description" : ""
}
@app.route('/',methods=['POST', 'GET'])
def index():
if request.method == 'POST':
pass
else:
online_users = mongo.db.users.find({"online": True})
return render_template("index.html", online_users=online_users)
@app.route('/search_test', methods=['POST', 'GET'])
def search():
# data structures of information
# productName = "swolo"
# ebayImg = "https://mercari-images.global.ssl.fastly.net/photos/m86893773555_1.jpg?1579372204&w=200&h=200&fitcrop&sharpen"
# ebayImg = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxIPDw8NEBAQDw8QEA8QEBAQEBYVEBAPFxUWFhYRFRUYHSggGBomGxUWITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OFg0PFy0lHh0xKzc3Nzc3NzcrNTArKy03KysrNC4vLSsrNS8rLSstKzc3LS03NysrLC0rKy0yLSstK//AABEIAP8AxgMBIgACEQEDEQH/xAAcAAEBAAIDAQEAAAAAAAAAAAAAAQcIAgUGBAP/xABEEAABAwIDBQUEBAsIAwAAAAABAAID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V3+98cvo5jR/CvKXQF2uBbNVlfmNJTPmawgPfdrI2nwzvIBPQXXTzPs1zuYBt58ltfgGEx0NNBRQtAbGwAuHF7rd+Q+LnHX1Qa/wD4tcW/yJPlPD/Uod22Lf5B/wCvg/rWyyqDWT8XGL/6dJ+vp/8AkT8W+L/6fJ+vp/8AkWzaINYn7usWAucOlt0lgPyEi81UU74nujkY6ORhLXse0tcxw5OB4cv2rcEhYg3+YLGIqbEWtAl7YU0rgNXsc1xZfxsWn7yDC5RCoFRlHcDFmrqp/wBSmbr+m8/0rO4WGP7PVL3sQm14QRHzF3fvWZwoKiIgIiICIiCKhREFREQFCqiDX7fjS5MVbL+epYiB+g5zT+1Y8WY9/WByvdS18bXPjjjkgkytJ7O5DmvdblxF+Swx2zPrt+IQfbh1P209PB+dqKaP70rB+9bb273p+9a4bq9nZKzEqWbs3GmpntqZJCCG5maxNa7mS/KbDk0rZBo1KDmiIgIiIC8DvvgzYNK/81PSSf8A1az+Ne+XRbb4Ma/DqyjFs8sLuzubDtm2fGSfDO1qDVUqH58vNc5mlrixwLHtcWvY4Wc1w4tI8VxI9Op4IM7bgqTLQVM3KapNvJjGtWUV4bc1QugweDMC3tpJp2ggg5Hu7pIPiBde5QEREBERAREQRERBUUVQEREHFzb6Hh4eK/H2KP8ANx/cb/JfQiDgyMN0AAHgBYLkAqiAiIgIiIChVRB1OI7N0dSc1RSU07vrSwtcb+NyF8MOwmGMcHtw+kDhYg9i3QjW4XpEQcWtt0XJEQEREBERAREQRERAREQFVFUBERAREQEREBERAREQEREBERAREQEREBERB//Z"
# ebayPrice = "25"
# mercariNames = ["mateo", "raf","shine"]
# mercariImages = ["https://mercari-images.global.ssl.fastly.net/photos/m86893773555_1.jpg?1579372204&w=200&h=200&fitcrop&sharpen", "https://mercari-images.global.ssl.fastly.net/photos/m86893773555_1.jpg?1579372204&w=200&h=200&fitcrop&sharpen", "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxIPD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FUBERAREQEREBERAREQEREBERAREQEREBERB//Z"]
# mercariPrices = ["40,30,15"]
# mercariDescrip = ["ugly", "more ugly", "super ugly"]
# lenMercari = len(mercariImages) # length of mercari objects
# return render_template('search.html',productName=productName,ebayImg = ebayImg, ebayPrice=ebayPrice,mercariNames=mercariNames,mercariImages=mercariImages,mercariPrices=mercariPrices,mercariDescrip=mercariDescrip,lenMercari=lenMercari)
# mercari information variables
mercariNames = []
mercariImages = []
mercariPrices = []
mercariDescrip = []
mercariLinks = []
lenMercari = 0
if request.method == 'POST':
#secure search
if 'secureSearch' in request.form:
mpn = getmpn(request.form['query'])
ebayinfo = ebayAPI(mpn).get_sold_items_info()
searches = mongo.db.searches
searches.insert({'item': request.form['query'], 'mpn': mpn, 'ebayavg': ebayinfo['AvgPrice'], 'date': datetime.datetime.utcnow()})
mercariList = get_items(request.form['query']+ " " + mpn, math.floor(ebayinfo['AvgPrice']*0.3), ebayinfo['AvgPrice'])
else:
print(request.form)
searches = mongo.db.searches
result = searches.find_one({'item': request.form['query']})
if not result:
newname = request.form['query'] #+ " " + getbrandmodel(request.form['query'])
ebayinfo = ebayAPI(newname).get_sold_items_info()
searches.insert({'item': newname, 'mpn': '', 'ebayavg': ebayinfo['AvgPrice'],
'date': datetime.datetime.utcnow()})
mercariList = get_items(newname, math.floor(ebayinfo['AvgPrice']*0.3), ebayinfo['AvgPrice'])
else:
print("hoi")
ebayinfo = {'Img': "", 'AvgPrice': math.floor(result['ebayavg'])}
mercariList = get_items(request.form['query'], math.floor(ebayinfo['AvgPrice'] * 0.3), math.floor(ebayinfo['AvgPrice']))
print(ebayinfo['AvgPrice'])
print(math.floor(ebayinfo['AvgPrice'] * 0.3))
for item in mercariList:
mercariNames.append(item['name'])
mercariImages.append(item['image'])
mercariPrices.append(item['offers']["price"])
mercariDescrip.append(item["description"])
mercariLinks.append("https://mercari.com" + item['offers']['url'])
lenMercari = len(mercariNames)
print("lenght of items from mercari " + str(len(mercariList)))
# ebay variables
productName = request.form["query"]
ebayImg = ebayinfo['Img']
ebayPrice = ebayinfo['AvgPrice']
return render_template('search_test.html',productName=productName,ebayImg = ebayImg, ebayPrice=ebayPrice,mercariNames=mercariNames,mercariImages=mercariImages,mercariPrices=mercariPrices,mercariDescrip=mercariDescrip,mercariLinks=mercariLinks,lenMercari=lenMercari)
return render_template('search_test.html', lenMercari=0)
if __name__ == '__main__':
app.run(debug=True)