diff options
Diffstat (limited to 'cgi')
-rwxr-xr-x | cgi/gb.cgi | 47 | ||||
-rwxr-xr-x | cgi/rgb.cgi | 10 | ||||
-rwxr-xr-x | cgi/weather | 24 | ||||
-rwxr-xr-x | cgi/weather.sh | 7 |
4 files changed, 88 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 Выйти из гостевой") diff --git a/cgi/rgb.cgi b/cgi/rgb.cgi new file mode 100755 index 0000000..84fce1f --- /dev/null +++ b/cgi/rgb.cgi @@ -0,0 +1,10 @@ +#!/bin/bash + +#printf "20 text/plain\r\n" +printf "20 text/gemini\r\n" +/usr/bin/cat /srv/gemini/gb.gmi +echo "" +#echo "=>/cgi-bin/rgb.cgi Читать гостевую" +echo "=> gemini://phreedom.club/cgi-bin/gb.cgi Писать в гостевую" +echo "=> gemini://phreedom.club/~tolstoevsky/index.gmi На капсулу Tolstoevsky" +echo "=> gemini://phreedom.club/index.gmi На капсулу Phreedom" diff --git a/cgi/weather b/cgi/weather new file mode 100755 index 0000000..5590e83 --- /dev/null +++ b/cgi/weather @@ -0,0 +1,24 @@ +#!/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("````") +#print (text) + +print(subprocess.Popen(["ansiweather", "-F", "-u", "metric", "-a", "false", "-w", "true", "-p", "true", "-d", "true", "-s", "false", "-l" , text ], stdout=subprocess.PIPE).stdout.read()) +#print("````") diff --git a/cgi/weather.sh b/cgi/weather.sh new file mode 100755 index 0000000..791417c --- /dev/null +++ b/cgi/weather.sh @@ -0,0 +1,7 @@ +#!/bin/bash +if [[ -n ${QUERY_STRING} && ${QUERY_STRING} =~ ${re} ]] ; then + printf "20 text/gemini\r\n $(ansiweather -F -u metric -a false -w true -p true -d true -s true -l ${QUERY_STRING}| sed 's/-/\n/g' | sed 's/=/\n/g' )\r\n --- \r\n Источник - OpenWeatherMap" + +else + printf "10 введите город (латиницей)" +fi |