-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
129 lines (100 loc) · 3.16 KB
/
app.py
File metadata and controls
129 lines (100 loc) · 3.16 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from flask import Flask
from flask import request, Response, render_template, redirect, url_for, send_file
# import get_image
import sqlalchemy
from sqlalchemy.orm import sessionmaker, scoped_session
#Change this path when running on your system if needed. Database is in the current working directory.
engine = sqlalchemy.create_engine('sqlite:///cve')
app = Flask(__name__)
# disable cache
@app.after_request
def add_header(r):
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
return r
@app.route("/")
def index():
return render_template("main.html")
@app.route("/styleGuide")
def styles():
return render_template("styleGuide.html")
@app.route("/vendors")
def vendors():
return render_template("byVendor.html")
@app.route("/products")
def products():
return render_template("byProduct.html")
@app.route("/main1")
def main1():
return render_template("main1.html")
@app.route("/main2")
def main2():
return render_template("main2.html")
@app.route("/not-allowed")
def notAllowed():
return render_template("not-allowed.html")
@app.route("/sample")
def sample():
return render_template("sample.html")
@app.route("/product-search")
def productSearch():
return render_template("product-search.html")
@app.route("/searchquery")
def searchquery():
return render_template("searchquery.html")
@app.route("/apple")
def apple():
return render_template("apple.html")
@app.route("/appache")
def appache():
return render_template("appache.html")
@app.route("/adobe")
def adobe():
return render_template("adobe.html")
@app.route("/oracle")
def oracle():
return render_template("oracle.html")
@app.route("/microsoft")
def microsoft():
return render_template("microsoft.html")
@app.route("/linux")
def linux():
return render_template("linux.html")
@app.route("/ibn")
def ibn():
return render_template("ibn.html")
@app.route("/google")
def google():
return render_template("google.html")
@app.route("/devian")
def devian():
return render_template("devian.html")
@app.route("/api/v1/query", methods=["GET", "POST"])
def query():
out = ""
if request.method == "POST":
if request.form["query"]:
query = request.form["query"]
Session = scoped_session(sessionmaker(bind=engine))
s = Session()
try:
# ooooo scaryyy! FIXME: sanitize/escape user input!!!
print(query)
result = s.execute(query)
print(result)
# iterate through results
for item in result:
#print(item)
out = out + str(item) + " \n"
print("Query Successful.")
return out
except:
print("Query Failed.")
return "Invalid SQL Statement or SQL error."
else:
return "No Query."
else:
return ">:("
if __name__ == '__main__':
Flask.run(app, port="7777", debug=True)