From 109ec9a7d86bcadb16541873d95068f737586692 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Fri, 10 Jul 2020 20:30:54 +0800 Subject: Enhance blob view Changes: - set maximum size of displayable blobs - raw blobs are now of type `bytes` - do not try to decode handle binary blobs --- git-gmi/gateway.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-gmi/gateway.py') diff --git a/git-gmi/gateway.py b/git-gmi/gateway.py index 29f0268..b0c9b0a 100644 --- a/git-gmi/gateway.py +++ b/git-gmi/gateway.py @@ -2,6 +2,7 @@ from git import * from const import * from config import * from os import environ, listdir +import sys # be careful when using print(); stdout is passed to the client. # this cgi uses \n as newline. @@ -56,7 +57,7 @@ def handle_cgi_request(path: str, query: str): except FileNotFoundError: # is file try: if query == "raw": - print(repo.view_raw_blob(branch, location)) + sys.stdout.buffer.write(repo.view_raw_blob(branch, location)) else: print(repo.view_blob(branch, location)) except FileNotFoundError: -- cgit v1.2.3