45 lines
1.2 KiB
Python
45 lines
1.2 KiB
Python
import secrets
|
|
|
|
# TODO
|
|
# FIX
|
|
# WARNING
|
|
|
|
from flask import Flask, flash, redirect, render_template, request, session, url_for
|
|
from markupsafe import escape
|
|
|
|
import host_lookup
|
|
import upload
|
|
|
|
app = Flask(__name__)
|
|
generate_secret = secrets.token_urlsafe(16)
|
|
app.secret_key = generate_secret
|
|
|
|
|
|
@app.route("/")
|
|
def index():
|
|
return redirect(url_for("lookup"))
|
|
|
|
|
|
@app.route("/lookup", methods=["GET", "POST"])
|
|
def lookup():
|
|
hosts = []
|
|
if request.method == "GET":
|
|
return render_template("lookup.html")
|
|
elif request.method == "POST" and "host" in request.form:
|
|
user_input = escape(request.form.get("host").strip())
|
|
if len(user_input) >= 1:
|
|
hosts = host_lookup.process_input(user_input)
|
|
return render_template("results.html", hosts=hosts)
|
|
else:
|
|
flash("YA DONE FUCKED UP", "error")
|
|
return render_template("lookup.html")
|
|
elif request.method == "POST" and "file" in request.files:
|
|
file = request.files["file"]
|
|
extracted = upload.extract(file)
|
|
hosts = host_lookup.process_file(extracted)
|
|
return render_template("results.html", hosts=hosts)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(debug=True)
|