gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

75aea8fc1fbb8537b33b96eea4f879704e466489 - Matthew Ernisse - 1614710785

test needs_input

view tree

view raw

diff --git a/cgi-bin/gmicgi/__init__.py b/cgi-bin/gmicgi/__init__.py
index 13e6f1b..c720d28 100755
--- a/cgi-bin/gmicgi/__init__.py
+++ b/cgi-bin/gmicgi/__init__.py
@@ -128,7 +128,7 @@ class GeminiCGI(object):
 			self.query_parsed = parse_qs(self.query_string)
 
 	def certificate_required(self, f):
-		''' Return a 61 if a certificate isn't presented. '''
+		''' Return a 60 if a client certificate isn't presented. '''
 		def decorator():
 			if not self.client_cert:
 				return self.Response.NeedCert()
@@ -164,3 +164,6 @@ class GeminiCGI(object):
 		if self.path_info in self.routes.keys():
 			for func in self.routes[self.path_info]:
 				func()
+
+		else:
+			self.Response.NotFound()
diff --git a/cgi-bin/needinput.py b/cgi-bin/needinput.py
new file mode 100755
index 0000000..3ad367c
--- /dev/null
+++ b/cgi-bin/needinput.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+from gmicgi import GeminiCGI
+
+cgi = GeminiCGI()
+
+@cgi.route('')
+@cgi.needs_input('> ')
+def default():
+	''' This should be the default route.'''
+	cgi.Response.Ok('text/gemini')
+	print('''
+
+This is a CGI test.  Below enumerates the environment passed by the server to the script.
+
+```
+''')
+	for k, v in os.environ.items():
+		print(f'{k}={v}')
+
+	print()
+	print('''
+
+And below here are any parameters passed to the script itself.
+
+```
+''')
+
+	print(sys.argv[1:])
+	print()
+	print('```')
+
+if __name__ == '__main__':
+	cgi.run()