aboutsummaryrefslogtreecommitdiff
path: root/cgi/gb.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/gb.cgi')
-rwxr-xr-xcgi/gb.cgi47
1 files changed, 47 insertions, 0 deletions
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 Выйти из гостевой")