From 91406f02b2a87e0dbfaf8a391edd049c25563848 Mon Sep 17 00:00:00 2001 From: sn4il Date: Tue, 27 Jun 2023 10:59:14 +0300 Subject: Initial commit --- cgi/gb.cgi | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 cgi/gb.cgi (limited to 'cgi/gb.cgi') diff --git a/cgi/gb.cgi b/cgi/gb.cgi new file mode 100755 index 0000000..cf14ab8 --- /dev/null +++ b/cgi/gb.cgi @@ -0,0 +1,47 @@ +#!/usr/bin/python3 + +import os +import subprocess +import sys +import urllib.parse + +import datetime +from datetime import date + +query = os.environ["QUERY_STRING"] +if not query: + print("10 Напишите сообщение и нажмите \"Enter\".") + sys.exit() + +text = urllib.parse.unquote(query) + +print("20 text/gemini") + +#print (text) + +#today = date.today() +file1 = open("/opt/gemini/gb.gmi", "a") # append mode +file1.write('%s.\n' % (datetime.datetime.now())) +file1.write(" ") +file1.write(text) +file1.write("\n\n") +file1.close() + + +try: + proc = subprocess.run( + ["/usr/bin/cat","/opt/gemini/gb.gmi"], +# input="/var/gemini/gb.gmi", + capture_output=True, + check=True, + text=True, + ) +except: + print("42 Unexpected Error") +else: +# print("20 text/plain") + print(proc.stdout) + +#print("=> /cgi-bin/rgb.cgi Читать гостевую") +print("=> gemini://gemini.phreedom.club:1968/cgi-bin/gb.cgi Писать в гостевую") +print("=> gemini://gemini.phreedom.club:1968/index.gmi Выйти из гостевой") -- cgit v1.2.3