main.py (1056B)
1 import argparse 2 3 import jetforce 4 5 from . import app, gus 6 7 8 def parse_args(): 9 parser = argparse.ArgumentParser() 10 11 parser.add_argument("--host", help="Server address to bind to", default="127.0.0.1") 12 parser.add_argument("--port", help="Server port to bind to", type=int, default=1965) 13 parser.add_argument("--hostname", help="Server hostname", default="localhost") 14 parser.add_argument( 15 "--tls-certfile", 16 dest="certfile", 17 help="Server TLS certificate file", 18 metavar="FILE", 19 ) 20 parser.add_argument( 21 "--tls-keyfile", 22 dest="keyfile", 23 help="Server TLS private key file", 24 metavar="FILE", 25 ) 26 27 return parser.parse_args() 28 29 30 def main(): 31 args = parse_args() 32 server = jetforce.GeminiServer( 33 app=app, 34 host=args.host, 35 port=args.port, 36 hostname=args.hostname, 37 certfile=args.certfile, 38 keyfile=args.keyfile, 39 ) 40 try: 41 server.run() 42 finally: 43 gus.index.close() 44 45 46 if __name__ == "__main__": 47 main()