R-Kentaren commited on
Commit
7734b88
·
verified ·
1 Parent(s): 3a6c93a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +104 -1
app.py CHANGED
@@ -471,4 +471,107 @@ async def healthz():
471
  app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
472
 
473
  if __name__ == "__main__":
474
- app.launch(server_name="0.0.0.0", server_port=7860, show_error=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
472
 
473
  if __name__ == "__main__":
474
+ import argparse
475
+ import inspect
476
+
477
+ parser = argparse.ArgumentParser(
478
+ description="ChatUI Studio — local AI chat server",
479
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
480
+ )
481
+ parser.add_argument(
482
+ "--host", "--server-name", dest="server_name", default="0.0.0.0",
483
+ help="Host/IP to bind to.",
484
+ )
485
+ parser.add_argument(
486
+ "--port", "--server-port", dest="server_port", type=int, default=7860,
487
+ help="Port to listen on.",
488
+ )
489
+ parser.add_argument(
490
+ "--share", dest="share", action="store_true",
491
+ help="Create a public Gradio share link.",
492
+ )
493
+ parser.add_argument(
494
+ "--no-share", dest="share", action="store_false",
495
+ help="Disable public share link.",
496
+ )
497
+ parser.set_defaults(share=False)
498
+ parser.add_argument(
499
+ "--show-error", dest="show_error", action="store_true",
500
+ help="Show full error tracebacks in the UI.",
501
+ )
502
+ parser.add_argument(
503
+ "--no-show-error", dest="show_error", action="store_false",
504
+ help="Hide error tracebacks in the UI.",
505
+ )
506
+ parser.set_defaults(show_error=True)
507
+ parser.add_argument(
508
+ "--quiet", action="store_true",
509
+ help="Suppress Gradio startup messages.",
510
+ )
511
+ parser.add_argument(
512
+ "--auth", nargs=2, metavar=("USER", "PASS"), default=None,
513
+ help="Enable basic auth with USER and PASS.",
514
+ )
515
+ parser.add_argument(
516
+ "--ssl-keyfile", default=None,
517
+ help="Path to SSL key file (enables HTTPS).",
518
+ )
519
+ parser.add_argument(
520
+ "--ssl-certfile", default=None,
521
+ help="Path to SSL certificate file.",
522
+ )
523
+ parser.add_argument(
524
+ "--ssl-keyfile-password", default=None,
525
+ help="Password for the SSL key file, if any.",
526
+ )
527
+ parser.add_argument(
528
+ "--favicon-path", default=None,
529
+ help="Path to a custom favicon.",
530
+ )
531
+ parser.add_argument(
532
+ "--allowed-paths", nargs="*", default=None,
533
+ help="Extra paths Gradio is allowed to serve from.",
534
+ )
535
+ parser.add_argument(
536
+ "--blocked-paths", nargs="*", default=None,
537
+ help="Paths Gradio must never serve.",
538
+ )
539
+ parser.add_argument(
540
+ "--max-file-size", default=None,
541
+ help="Max upload size (e.g. '10mb', '1gb').",
542
+ )
543
+
544
+ args = parser.parse_args()
545
+
546
+ launch_kwargs = {
547
+ "server_name": args.server_name,
548
+ "server_port": args.server_port,
549
+ "share": args.share,
550
+ "show_error": args.show_error,
551
+ "quiet": args.quiet,
552
+ "auth": tuple(args.auth) if args.auth else None,
553
+ }
554
+ if args.ssl_keyfile:
555
+ launch_kwargs["ssl_keyfile"] = args.ssl_keyfile
556
+ if args.ssl_certfile:
557
+ launch_kwargs["ssl_certfile"] = args.ssl_certfile
558
+ if args.ssl_keyfile_password:
559
+ launch_kwargs["ssl_keyfile_password"] = args.ssl_keyfile_password
560
+ if args.favicon_path:
561
+ launch_kwargs["favicon_path"] = args.favicon_path
562
+ if args.allowed_paths:
563
+ launch_kwargs["allowed_paths"] = args.allowed_paths
564
+ if args.blocked_paths:
565
+ launch_kwargs["blocked_paths"] = args.blocked_paths
566
+ if args.max_file_size:
567
+ launch_kwargs["max_file_size"] = args.max_file_size
568
+
569
+ # Drop kwargs that aren't supported by this Gradio version.
570
+ try:
571
+ supported = set(inspect.signature(app.launch).parameters.keys())
572
+ if "kwargs" not in supported:
573
+ launch_kwargs = {k: v for k, v in launch_kwargs.items() if k in supported}
574
+ except (TypeError, ValueError):
575
+ pass
576
+
577
+ app.launch(**launch_kwargs)