This repository was archived by the owner on Dec 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
40 lines (34 loc) · 1.23 KB
/
app.py
File metadata and controls
40 lines (34 loc) · 1.23 KB
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
from flask import Flask, render_template, request, url_for, Markup
import getString, getImage, os
app = Flask(__name__)
# setting up the basic route
@app.route("/")
def index():
return render_template('index.html')
@app.route("/product")
def product():
return render_template("product.html")
@app.route("/get_data", methods=['POST'])
def handle_data():
textBox = request.form["ideaBox"]
indexValues = getString.processString(textBox)
searchTerms = getString.getSearchValues(indexValues, textBox)
arrayLinks = getImage.main(searchTerms)
termCounter = 0
termInfo = ""
code = ""
for linkAddress in arrayLinks:
linkAddress1 = linkAddress.strip("}")
code += '<a href="' + linkAddress1 + '">' + '<img class="img-circle" src="'+ linkAddress1 + '" ></a>'
for term in searchTerms:
if termCounter == 0:
termInfo += term.strip("\n")
termInfo += " "
termCounter += 1
else:
termInfo += ", " + term.strip("\n")
termInfo += " "
return render_template("product.html",images= Markup(code),termInfo=termInfo,textBox=textBox)
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=port)