gemini.git

going-flying.com gemini git repository

summary

tree

log

refs

883542e9db51447f5ddcfb81c548cf85608fdd12 - Matthew Ernisse - 1614644317

I think this is a thing

view tree

view raw

diff --git a/cgi-bin/example.py b/cgi-bin/example.py
index 9b9076b..60edfcd 100755
--- a/cgi-bin/example.py
+++ b/cgi-bin/example.py
@@ -31,3 +31,6 @@ And below here are any parameters passed to the script itself.
 	print(sys.argv[1:])
 	print()
 	print('```')
+
+if __name__ == '__main__':
+	cgi.run()
diff --git a/cgi-bin/gmicgi/__init__.py b/cgi-bin/gmicgi/__init__.py
index 2de0f93..93cf6e3 100755
--- a/cgi-bin/gmicgi/__init__.py
+++ b/cgi-bin/gmicgi/__init__.py
@@ -98,10 +98,6 @@ class GeminiCGI(object):
 		''' Setup an instance of the GeminiCGI processor, which will
 		process the PATH_INFO and QUERY_STRING environment variables.
 
-		It also will walk through all the functions that were decorated
-		with the route decorator and if they match the current
-		PATH_INFO, it will call them.  You are of course free to not
-		use the routing though.
 		'''
 		self.path_info = os.environ.get('PATH_INFO', '')
 		self.routes = {}
@@ -115,10 +111,6 @@ class GeminiCGI(object):
 			self.query_dequoted = unquote(self.query_string)
 			self.query_parsed = parse_qs(self.query_string)
 
-		if self.path_info in self.routes.keys():
-			for func in self.routes[self.path_info]:
-				func()
-
 	def route(self, path):
 		''' Decorator to create a route.'''
 		def decorator(f):
@@ -129,3 +121,9 @@ class GeminiCGI(object):
 			return f
 
 		return decorator
+
+	def run(self):
+		''' Run the route engine.'''
+		if self.path_info in self.routes.keys():
+			for func in self.routes[self.path_info]:
+				func()