-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (23 loc) · 729 Bytes
/
app.py
File metadata and controls
30 lines (23 loc) · 729 Bytes
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
import os
import lief
import flask
import predict
app = flask.Flask(__name__)
@app.route('/')
def index():
return flask.render_template("index.html")
@app.route("/uploader", methods = ["POST"])
def upload_file():
peFile = flask.request.files["pe"]
model = flask.request.files["model"]
with open("model_temp.mdl", "wb") as f:
f.write(model.read())
try:
_ = lief.PE.parse(list(peFile.read()))
except:
return flask.render_template("invalid.html")
typeClass = predict.Prediction(peFile.read(), "model_temp.mdl")
os.remove("model_temp.mdl")
return flask.render_template("prediction.html", typeClass = typeClass)
if __name__ == "__main__":
app.run(debug=True)