~sircmpwn/cgi-scripts

64f3b493a5fe3a6a3014807de30da88540318da2 — Drew DeVault 4 years ago 6dd0da3
Add web.sh
2 files changed, 12 insertions(+), 2 deletions(-)

M hn.py
A web.sh
M hn.py => hn.py +1 -2
@@ 7,7 7,6 @@ import requests
import subprocess
import sys

gemini_url = os.environ["GEMINI_URL"]
query_string = os.environ.get("QUERY_STRING")
path = os.environ.get("PATH_INFO")
if not path or path == "/":


@@ 41,7 40,7 @@ if not path or path == "/":
    print("# Hacker News\n")
    for post in posts:
        url = post['url']
        print(f"=> {gemini_url}/view?{quote(url)} {post['title']}")
        print(f"=> web.sh?{quote(url)} {post['title']}")
elif path == "/view":
    sys.stdout.write("20 text/gemini\r\n")
    sys.stdout.flush()

A web.sh => web.sh +11 -0
@@ 0,0 1,11 @@
#!/bin/sh
if [ "$QUERY_STRING" = "" ]
then
	printf "10 Enter an web url\r\n"
	return
fi

printf "20 text/gemini\r\n"
printf "NOTICE: This page was automatically generated from HTML. Your mileage may vary.\n\n"
node web2gmi.js "$QUERY_STRING"
printf "---\n\n=> %s View original (http)" "$QUERY_STRING"