clortho

clortho is a very simple key/value server
git clone https://www.brianlane.com/git/clortho
Log | Files | Refs | README | LICENSE

commit 122bff8060451dcbfcbb4b7a6446867e80589523
parent ae981a5476c274fe330fa6b2b34bed75120b5dc4
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Wed,  5 Apr 2017 07:13:16 -0700

Change Content-Type to text/plain and text/html

Diffstat:
Msrc/clortho.py | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/clortho.py b/src/clortho.py @@ -45,18 +45,18 @@ def get_client(request): def get_version(request): text = "version: %s" % VERSION status = 200 - return web.Response(body=text.encode('utf-8'), status=status) + return web.Response(text=text, status=status) @asyncio.coroutine def show_info(request): - text = "<pre>\n" + text = "<html><body><pre>\n" text += "\n".join("%s = %s" % (hdr, request.headers[hdr]) for hdr in request.headers) peername = request.transport.get_extra_info('peername') if peername is not None: text += "\npeer = %s:%s\n" % (peername[0], peername[1]) - text += "</pre>\n" + text += "</pre></body></html>\n" - return web.Response(body=text.encode('utf-8'), status=200) + return web.Response(text=text, content_type="text/html", status=200) @asyncio.coroutine def get_key(request): @@ -69,7 +69,7 @@ def get_key(request): else: text = "%s doesn't exist for %s" % (key, client) status = 404 - return web.Response(body=text.encode('utf-8'), status=status) + return web.Response(text=text, status=status) @asyncio.coroutine def set_key(request): @@ -90,7 +90,7 @@ def set_key(request): text = "ERROR" status = 404 - return web.Response(body=text.encode('utf-8'), status=status) + return web.Response(text=text, status=status) @asyncio.coroutine def init(loop, host, port):