mckabue commited on
Commit
babceda
·
1 Parent(s): f37aff9

Refactor domain checking response and update HTML display for unsupported TLDs

Browse files
Files changed (2) hide show
  1. app.py +7 -3
  2. index.html +1 -1
app.py CHANGED
@@ -13,7 +13,7 @@ app = Flask(__name__)
13
  unsupported_TLDs = [
14
  {
15
  "tld": '.ly',
16
- "check": "https://reg.ly/ly-domain/"
17
  }
18
  ]
19
 
@@ -38,12 +38,16 @@ def check_domain(domain: str):
38
  return {
39
  'domain': domain,
40
  "available": False,
41
- "method": "Unsupported TLD"
42
  }
43
 
44
  result = check_domain_availability(domain)
45
  if result:
46
- return { "domain": domain, **result }
 
 
 
 
47
  except:
48
  pass
49
  return {
 
13
  unsupported_TLDs = [
14
  {
15
  "tld": '.ly',
16
+ "try": "https://reg.ly/ly-domain/"
17
  }
18
  ]
19
 
 
38
  return {
39
  'domain': domain,
40
  "available": False,
41
+ "method": f"Unsupported TLD, try at {unsupported_TLD.get('try')}"
42
  }
43
 
44
  result = check_domain_availability(domain)
45
  if result:
46
+ return {
47
+ "domain": domain,
48
+ "method": f"Checked via {result['method']}",
49
+ "available": result['available']
50
+ }
51
  except:
52
  pass
53
  return {
index.html CHANGED
@@ -59,7 +59,7 @@
59
  resultText.innerHTML = `
60
  <div class="alert ${data.available ? 'alert-success' : 'alert-danger'} mt-3">
61
  <strong>${data.domain ?? domain}</strong> is ${data.available ? 'available' : 'not available'}
62
- ${data.method ? `<br>(checked via ${data.method})` : ''}
63
  </div>
64
  `;
65
  } catch (err) {
 
59
  resultText.innerHTML = `
60
  <div class="alert ${data.available ? 'alert-success' : 'alert-danger'} mt-3">
61
  <strong>${data.domain ?? domain}</strong> is ${data.available ? 'available' : 'not available'}
62
+ ${data.method ? `<br><i>(${data.method})</i>` : ''}
63
  </div>
64
  `;
65
  } catch (err) {