diff --git a/localwhoami.py b/localwhoami.py new file mode 100644 index 0000000..e7152cc --- /dev/null +++ b/localwhoami.py @@ -0,0 +1,59 @@ +import base64 +import qrcode +import argparse +import flask; from flask import request +import socket +import sys +import io + +def localwhoami(port): + site = flask.Flask(__name__) + my_ip = socket.gethostbyname(socket.gethostname()) + print(my_ip) + my_url = f'http://{my_ip}:{port}' + url_qr = qrcode.make(my_url, border=0) + png_bytes = io.BytesIO() + url_qr.save(png_bytes, format='png') + png_bytes.seek(0) + png_bytes = png_bytes.read() + png_base64 = base64.b64encode(png_bytes).decode('ascii') + + @site.route('/') + def root(): + ip = request.remote_addr + if ip == '127.0.0.1': + ip = my_ip + return f''' + + + +