PEP8 cleanups
This commit is contained in:
parent
2351db1e1f
commit
05d5b74544
1 changed files with 12 additions and 7 deletions
15
chainlink.py
15
chainlink.py
|
@ -16,8 +16,9 @@ def root():
|
||||||
helptext = f"""
|
helptext = f"""
|
||||||
<p>General format is {host}/<domain>/<action>
|
<p>General format is {host}/<domain>/<action>
|
||||||
<p>If <action> is blank, it will attempt to use the IPFS hash
|
<p>If <action> is blank, it will attempt to use the IPFS hash
|
||||||
<p>You may also/optionally specify an action which can be any of the following
|
<p>You may also/optionally specify an action which can be any of the
|
||||||
<table margin-left="100px">
|
following
|
||||||
|
<table style="margin-left: 50px;border=1px;">
|
||||||
<tr>
|
<tr>
|
||||||
<td>raw</td>
|
<td>raw</td>
|
||||||
<td>Show the raw json (formatted as an html table)</td>
|
<td>Show the raw json (formatted as an html table)</td>
|
||||||
|
@ -28,7 +29,8 @@ def root():
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>redir</td>
|
<td>redir</td>
|
||||||
<td>Use the redirect parameter and just return a 302 redirect to whatever is set</td>
|
<td>Use the redirect parameter and just return a 302 redirect to whatever
|
||||||
|
is set</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
"""
|
"""
|
||||||
|
@ -55,7 +57,8 @@ def redirectDomain(domain, action=None):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return f'Did not find a redirect for {domain}'
|
return f'Did not find a redirect for {domain}'
|
||||||
elif action is None or action == 'html':
|
elif action is None or action == 'html':
|
||||||
# TODO: clean this up by functionalizing this call. It's basically the same as above
|
# TODO: clean this up by functionalizing this call.
|
||||||
|
# It's basically the same as above
|
||||||
if dnslookup.status_code == 200:
|
if dnslookup.status_code == 200:
|
||||||
body = json.loads(dnslookup.content)
|
body = json.loads(dnslookup.content)
|
||||||
print(body)
|
print(body)
|
||||||
|
@ -64,11 +67,13 @@ def redirectDomain(domain, action=None):
|
||||||
ipfshash = "ipfs/" + body['ipfs']['html']
|
ipfshash = "ipfs/" + body['ipfs']['html']
|
||||||
else:
|
else:
|
||||||
ipfshash = body['ipfs']['html']
|
ipfshash = body['ipfs']['html']
|
||||||
response.set_header('Location', f"https://cloudflare-ipfs.com/{ipfshash}")
|
response.set_header('Location',
|
||||||
|
f"https://cloudflare-ipfs.com/{ipfshash}")
|
||||||
elif action == 'raw':
|
elif action == 'raw':
|
||||||
if dnslookup.status_code == 200:
|
if dnslookup.status_code == 200:
|
||||||
body = json.loads(dnslookup.content)
|
body = json.loads(dnslookup.content)
|
||||||
return json2html.json2html.convert(json=body)
|
return json2html.json2html.convert(json=body)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run(app, host='0.0.0.0', port='5000', reloader=True)
|
run(app, host='0.0.0.0', port='5000', reloader=True)
|
||||||
|
|
Loading…
Reference in a new issue