Initial Commit

main
Bryan Cerrati 2025-03-04 12:48:31 -05:00
commit 431bde4e44
3 changed files with 94 additions and 0 deletions

33
app.py Normal file
View File

@ -0,0 +1,33 @@
from flask import Flask, render_template, request, redirect, url_for
import whois
app = Flask(__name__)
# In-memory list to store domain info. In production, you’d use a database.
domains = []
@app.route('/')
def home():
return render_template('home.html', domains=domains)
@app.route('/add', methods=['GET', 'POST'])
def add_domain():
if request.method == 'POST':
# Get a list of domains from the form (one or multiple)
domain_list = request.form.getlist('domain')
for domain in domain_list:
if domain.strip(): # ignore empty strings
try:
w = whois.whois(domain)
# Some WHOIS responses return a list of dates.
exp_date = w.expiration_date
if isinstance(exp_date, list):
exp_date = exp_date[0]
except Exception as e:
exp_date = f"Error: {e}"
domains.append({'domain': domain, 'expiration_date': exp_date})
return redirect(url_for('home'))
return render_template('add_domain.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5050, debug=True)

33
templates/add_domain.html Normal file
View File

@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Add Domain</title>
<script>
function addField() {
var container = document.getElementById("domainFields");
var input = document.createElement("input");
input.type = "text";
input.name = "domain";
input.placeholder = "Enter domain name";
// Create a line break for spacing
container.appendChild(document.createElement("br"));
container.appendChild(input);
}
</script>
</head>
<body>
<h1>Add Domain(s)</h1>
<form method="post">
<div id="domainFields">
<input type="text" name="domain" placeholder="Enter domain name">
</div>
<br>
<button type="button" onclick="addField()">Add Another</button>
<br><br>
<input type="submit" value="Save">
</form>
<br>
<a href="{{ url_for('home') }}">Back to Home</a>
</body>
</html>

28
templates/home.html Normal file
View File

@ -0,0 +1,28 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Domain List</title>
</head>
<body>
<h1>Domain List</h1>
<table border="1" cellpadding="5" cellspacing="0">
<thead>
<tr>
<th>Domain</th>
<th>Expiration Date</th>
</tr>
</thead>
<tbody>
{% for domain in domains %}
<tr>
<td>{{ domain.domain }}</td>
<td>{{ domain.expiration_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<br>
<a href="{{ url_for('add_domain') }}">Add Domain</a>
</body>
</html>