diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..acd8d96 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.11-slim + +# Install sipcalc and dependencies +RUN apt-get update && \ + apt-get install -y --no-install-recommends sipcalc && \ + rm -rf /var/lib/apt/lists/* + +# Set up app directory +WORKDIR /app + +# Install Flask +RUN pip install --no-cache-dir flask + +# Copy app code +COPY app.py . + +EXPOSE 5000 + +CMD ["python", "app.py"] \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..0e93b23 --- /dev/null +++ b/app.py @@ -0,0 +1,51 @@ +import subprocess +from flask import Flask, render_template_string, request + +app = Flask(__name__) + +HTML_TEMPLATE = """ + + +
+{{ output }}
+ {% endif %}
+
+
+"""
+
+@app.route("/", methods=["GET", "POST"])
+def index():
+ output = ""
+ query = ""
+ if request.method == "POST":
+ query = request.form.get("ipv6", "").strip()
+ if query:
+ try:
+ # Run sipcalc CLI command securely
+ result = subprocess.run(
+ ["sipcalc", query], capture_output=True, text=True, timeout=5
+ )
+ output = result.stdout if result.returncode == 0 else result.stderr
+ except Exception as e:
+ output = str(e)
+ return render_template_string(HTML_TEMPLATE, query=query, output=output)
+
+if __name__ == "__main__":
+ app.run(host="0.0.0.0", port=5000)
\ No newline at end of file