Add support for namespaces

This commit is contained in:
Tanner Collin 2022-08-11 20:33:56 +00:00
parent 516fdd0f6e
commit d944d91b3c

View File

@ -92,7 +92,16 @@ def new():
@flask_app.route('/<rid>', methods=['GET']) @flask_app.route('/<rid>', methods=['GET'])
def get(rid): def get(rid):
try: try:
return registers[rid], 200, {'Content-Type': 'text/plain; charset=utf-8'} if rid.endswith(':'):
response = 'Namespace ' + rid + '\n\n'
pairs = []
for key, value in registers.items():
if key.startswith(rid):
pairs.append(key.split(':')[1] + ':\n' + value)
response += '\n\n'.join(sorted(pairs))
else:
response = registers[rid]
return response, 200, {'Content-Type': 'text/plain; charset=utf-8'}
except: except:
abort(404) abort(404)