summaryrefslogtreecommitdiff
path: root/git-gmi/gateway.py
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@macaw.me>2020-07-10 20:30:54 +0800
committerFrederick Yin <fkfd@macaw.me>2020-07-10 20:30:54 +0800
commit109ec9a7d86bcadb16541873d95068f737586692 (patch)
tree405116ed82038be22f8fb0a234f57ebd1dc65400 /git-gmi/gateway.py
parenteb1bd1e074b81a428cb689d3a381e86e2fd530dd (diff)
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
Diffstat (limited to 'git-gmi/gateway.py')
-rw-r--r--git-gmi/gateway.py3
1 files changed, 2 insertions, 1 deletions
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: