aboutsummaryrefslogtreecommitdiff
path: root/cgi/gb.cgi
diff options
context:
space:
mode:
authorsn4il <sn4il@theplace>2023-06-27 10:59:14 +0300
committersn4il <sn4il@theplace>2023-06-27 10:59:14 +0300
commit91406f02b2a87e0dbfaf8a391edd049c25563848 (patch)
treeb06afb9bbc7e7c5e9aa74def727bdbb52bf8c365 /cgi/gb.cgi
downloadpubnix-91406f02b2a87e0dbfaf8a391edd049c25563848.tar.gz
pubnix-91406f02b2a87e0dbfaf8a391edd049c25563848.zip
Initial commit
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 Выйти из гостевой")