2019-08-21 03:17:58 +02:00
|
|
|
"""
|
|
|
|
A simple Gemini server that echos back the request to the client.
|
|
|
|
"""
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
import jetforce
|
|
|
|
|
|
|
|
|
2019-08-23 00:53:02 +02:00
|
|
|
def echo(environ, send_status):
|
2019-08-27 05:41:10 +02:00
|
|
|
url = environ["GEMINI_URL"]
|
2019-08-23 00:53:02 +02:00
|
|
|
send_status(jetforce.Status.SUCCESS, "text/gemini")
|
2019-08-21 03:17:58 +02:00
|
|
|
yield f"Received path: {url}".encode()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-08-23 00:53:02 +02:00
|
|
|
args = jetforce.command_line_parser().parse_args()
|
2019-08-29 04:33:58 +02:00
|
|
|
ssl_context = jetforce.make_ssl_context(
|
|
|
|
args.hostname, args.certfile, args.keyfile, args.cafile, args.capath
|
|
|
|
)
|
2019-08-21 03:17:58 +02:00
|
|
|
server = jetforce.GeminiServer(
|
|
|
|
host=args.host,
|
|
|
|
port=args.port,
|
2019-08-29 04:33:58 +02:00
|
|
|
ssl_context=ssl_context,
|
2019-08-21 03:17:58 +02:00
|
|
|
hostname=args.hostname,
|
|
|
|
app=echo,
|
|
|
|
)
|
|
|
|
asyncio.run(server.run())
|