jetforce/examples/echo_server.py

26 lines
580 B
Python
Raw Normal View History

"""
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):
url = environ["URL"]
2019-08-23 00:53:02 +02:00
send_status(jetforce.Status.SUCCESS, "text/gemini")
yield f"Received path: {url}".encode()
if __name__ == "__main__":
2019-08-23 00:53:02 +02:00
args = jetforce.command_line_parser().parse_args()
server = jetforce.GeminiServer(
host=args.host,
port=args.port,
certfile=args.certfile,
keyfile=args.keyfile,
hostname=args.hostname,
app=echo,
)
asyncio.run(server.run())