36 lines
969 B
Python
36 lines
969 B
Python
import os
|
|
import string
|
|
import random
|
|
|
|
def get_client_cert(ok_if_found = True):
|
|
TLS_CLIENT_HASH = os.getenv('TLS_CLIENT_HASH')
|
|
if (TLS_CLIENT_HASH is None):
|
|
show_header_cert_required()
|
|
elif ok_if_found:
|
|
show_header_ok()
|
|
return TLS_CLIENT_HASH
|
|
|
|
def get_query_string(msg, ok_if_found = True):
|
|
QUERY_STRING = os.getenv('QUERY_STRING')
|
|
if(QUERY_STRING is None):
|
|
show_query_string_required(msg)
|
|
elif ok_if_found:
|
|
show_header_ok()
|
|
return QUERY_STRING
|
|
|
|
def show_header_ok():
|
|
print("20 text/gemini; charset=utf-8", end = "\r\n")
|
|
|
|
def show_header_cert_required():
|
|
print("60 text/gemini; charset=utf-8", end = "\r\n")
|
|
quit()
|
|
|
|
def show_query_string_required(msg):
|
|
print("10 " + msg, end = "\r\n")
|
|
quit()
|
|
|
|
def id_generator(size=12, chars=string.ascii_uppercase + string.digits):
|
|
return ''.join(random.choice(chars) for _ in range(size))
|
|
|
|
#vim:fenc=utf-8:ts=4:sw=4:sta:noet:sts=4:fdm=marker:ai
|