Skip to content

Commit

Permalink
Add ipfs daemon version endpoint and means to retrieve it
Browse files Browse the repository at this point in the history
on the web admin page for #791
  • Loading branch information
machawk1 committed Mar 11, 2023
1 parent 7e46be0 commit 862143c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
15 changes: 15 additions & 0 deletions ipwb/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ class UnsupportedIPFSVersions(Exception):
def command_daemon(cmd):
if cmd == 'status':
return generate_daemon_status_button()
elif cmd == 'version':
try:
ipfs_version = ipfs_client().version()['Version']
status = 200
except:
ipfs_version = "Not Available"
status = 503
resp = Response(response=ipfs_version,
status=status,
mimetype="text/plain")

return resp
elif cmd == 'start':
subprocess.Popen(['ipfs', 'daemon'])
return Response('IPFS daemon starting...')
Expand Down Expand Up @@ -988,6 +1000,9 @@ def generate_daemon_status_button():
return Response(f'{status_page_html}{button_html}{footer}')


def get_daemon_version():
pass

def get_index_file_full_path(cdxj_file_path=INDEX_FILE):
# Avoid prepending current directory path to an IPFS hash.
if cdxj_file_path.startswith('Qm'):
Expand Down
14 changes: 6 additions & 8 deletions ipwb/templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ <h1><img src="./ipwbassets/logo.png" alt="ipwb" style="height: 50px; vertical-al
<section>
<h2>Status</h2>
<dl>
<dt>IPWB Version</dt>
<dd>{{ status.ipwb_version }}</dd>
<dt>IPFS Endpoint</dt>
<dd>{{ status.ipfs_endpoint }} (<a href="#" rel="noreferrer">Change</a> | <a href="#" rel="noreferrer">Web UI</a>)</dd>
<dt>IPFS Status</dt>
<dd>
<label id="daemonStatusLabel">IPFS Daemon: </label><iframe src="ipfsdaemon/status" id="daemonStatus"></iframe>
</dd>
<dt>IPWB</dt>
<dd>Version: {{ status.ipwb_version }}</dd>
<dt>IPFS</dt>
<dd>Endpoint: {{ status.ipfs_endpoint }} (<a href="#" rel="noreferrer">Change</a> | <a href="#" rel="noreferrer">Web UI</a>)</dd>
<dd><label id="daemonStatusLabel">Daemon Status:</label><iframe src="ipfsdaemon/status" id="daemonStatus"></iframe></dd>
<dd>Daemon Version:<iframe src="ipfsdaemon/version" id="daemonVersion"></iframe></dd>
</dl>
</section>
<section>
Expand Down

0 comments on commit 862143c

Please sign in to comment.