#!/usr/bin/env python """Utilize crypto domains DNS and either redirect, or display information.""" from bottle import Bottle, run, response, request, static_file import json import requests import json2html VERSION = '0.1.0' app = Bottle() def domainLookup(domain): """Return a dictionary from JSON results of API call or return False if there is an error """ try: apibase = 'https://unstoppabledomains.com/api/v1/' dnslookup = requests.get(apibase + domain) if dnslookup.status_code == 200: domainInfo = json.loads(dnslookup.content) return domainInfo else: return False except requests.exceptions.ConnectionError: return False @app.route("/") def root(): """Index page, just displays information about URL formatting""" host = request.get_header('host') helptext = f"""
General format is {host}/<domain>/<action>
If <action> is blank, it will attempt to use the IPFS hash
You may also/optionally specify an action which can be any of the following
raw | Show the raw json (formatted as an html table) |
html | Hit the IPFS hash via cloudflare-ipfs.com |
redir | Use the redirect parameter and just return a 302 redirect to whatever is set |