@@ -36,7 +36,7 @@ def serve_directory(
3636 "this option selected."
3737 ),
3838 ),
39- api_key : str = typer .Option (
39+ api_key : Optional [ str ] = typer .Option (
4040 None ,
4141 "--api-key" ,
4242 help = (
@@ -55,7 +55,7 @@ def serve_directory(
5555 "may break user (client-side) code."
5656 ),
5757 ),
58- ext : List [str ] = typer .Option (
58+ ext : Optional [ List [str ] ] = typer .Option (
5959 None ,
6060 "--ext" ,
6161 help = (
@@ -64,7 +64,7 @@ def serve_directory(
6464 "extension."
6565 ),
6666 ),
67- mimetype_detection_hook : str = typer .Option (
67+ mimetype_detection_hook : Optional [ str ] = typer .Option (
6868 None ,
6969 "--mimetype-hook" ,
7070 help = (
@@ -73,15 +73,15 @@ def serve_directory(
7373 "Specify here as 'package.module:function'"
7474 ),
7575 ),
76- adapters : List [str ] = typer .Option (
76+ adapters : Optional [ List [str ] ] = typer .Option (
7777 None ,
7878 "--adapter" ,
7979 help = (
8080 "ADVANCED: Custom Tiled Adapter for reading a given format"
8181 "Specify here as 'mimetype=package.module:function'"
8282 ),
8383 ),
84- walkers : List [str ] = typer .Option (
84+ walkers : Optional [ List [str ] ] = typer .Option (
8585 None ,
8686 "--walker" ,
8787 help = (
@@ -138,7 +138,7 @@ def serve_directory(
138138 stamp_head (ALEMBIC_INI_TEMPLATE_PATH , ALEMBIC_DIR , database )
139139
140140 from ..catalog import from_uri as catalog_from_uri
141- from ..server .app import build_app , print_admin_api_key_if_generated
141+ from ..server .app import build_app , print_server_info
142142
143143 server_settings = {}
144144 if keep_ext :
@@ -212,7 +212,7 @@ def serve_directory(
212212
213213 from ..client import from_uri as client_from_uri
214214
215- print_admin_api_key_if_generated (web_app , host = host , port = port , force = generated )
215+ print_server_info (web_app , host = host , port = port , include_api_key = generated )
216216 log_config = _setup_log_config (log_config , log_timestamps )
217217 config = uvicorn .Config (web_app , host = host , port = port , log_config = log_config )
218218 server = uvicorn .Server (config )
@@ -287,16 +287,16 @@ async def serve_and_walk():
287287
288288
289289def serve_catalog (
290- database : str = typer .Argument (
290+ database : Optional [ str ] = typer .Argument (
291291 None , help = "A filepath or database URI, e.g. 'catalog.db'"
292292 ),
293- read : List [str ] = typer .Option (
293+ read : Optional [ List [str ] ] = typer .Option (
294294 None ,
295295 "--read" ,
296296 "-r" ,
297297 help = "Locations that the server may read from" ,
298298 ),
299- write : List [str ] = typer .Option (
299+ write : Optional [ List [str ] ] = typer .Option (
300300 None ,
301301 "--write" ,
302302 "-w" ,
@@ -321,7 +321,7 @@ def serve_catalog(
321321 "this option selected."
322322 ),
323323 ),
324- api_key : str = typer .Option (
324+ api_key : Optional [ str ] = typer .Option (
325325 None ,
326326 "--api-key" ,
327327 help = (
@@ -363,7 +363,7 @@ def serve_catalog(
363363
364364 from ..catalog import from_uri
365365 from ..catalog .utils import classify_writable_storage
366- from ..server .app import build_app , print_admin_api_key_if_generated
366+ from ..server .app import build_app , print_server_info
367367
368368 parsed_database = urllib .parse .urlparse (database )
369369 if parsed_database .scheme in ("" , "file" ):
@@ -477,7 +477,9 @@ def serve_catalog(
477477 server_settings ,
478478 scalable = scalable ,
479479 )
480- print_admin_api_key_if_generated (web_app , host = host , port = port )
480+ print_server_info (
481+ web_app , host = host , port = port , include_api_key = api_key is not None
482+ )
481483
482484 import uvicorn
483485
@@ -502,7 +504,7 @@ def serve_pyobject(
502504 "option selected."
503505 ),
504506 ),
505- api_key : str = typer .Option (
507+ api_key : Optional [ str ] = typer .Option (
506508 None ,
507509 "--api-key" ,
508510 help = (
@@ -534,7 +536,7 @@ def serve_pyobject(
534536 ),
535537):
536538 "Serve a Tree instance from a Python module."
537- from ..server .app import build_app , print_admin_api_key_if_generated
539+ from ..server .app import build_app , print_server_info
538540 from ..utils import import_object
539541
540542 tree = import_object (object_path )
@@ -548,7 +550,7 @@ def serve_pyobject(
548550 server_settings ,
549551 scalable = scalable ,
550552 )
551- print_admin_api_key_if_generated (web_app , host = host , port = port )
553+ print_server_info (web_app , host = host , port = port , include_api_key = api_key is None )
552554
553555 import uvicorn
554556
@@ -569,13 +571,13 @@ def serve_demo(
569571 port : int = typer .Option (8000 , help = "Bind to a socket with this port." ),
570572):
571573 "Start a public server with example data."
572- from ..server .app import build_app , print_admin_api_key_if_generated
574+ from ..server .app import build_app , print_server_info
573575 from ..utils import import_object
574576
575577 EXAMPLE = "tiled.examples.generated:tree"
576578 tree = import_object (EXAMPLE )
577579 web_app = build_app (tree , {"allow_anonymous_access" : True }, {})
578- print_admin_api_key_if_generated (web_app , host = host , port = port )
580+ print_server_info (web_app , host = host , port = port , include_api_key = True )
579581
580582 import uvicorn
581583
@@ -584,7 +586,7 @@ def serve_demo(
584586
585587@serve_app .command ("config" )
586588def serve_config (
587- config_path : Path = typer .Argument (
589+ config_path : Optional [ Path ] = typer .Argument (
588590 None ,
589591 help = (
590592 "Path to a config file or directory of config files. "
@@ -601,23 +603,23 @@ def serve_config(
601603 "option selected."
602604 ),
603605 ),
604- api_key : str = typer .Option (
606+ api_key : Optional [ str ] = typer .Option (
605607 None ,
606608 "--api-key" ,
607609 help = (
608610 "Set the single-user API key. "
609611 "By default, a random key is generated at startup and printed."
610612 ),
611613 ),
612- host : str = typer .Option (
614+ host : Optional [ str ] = typer .Option (
613615 None ,
614616 help = (
615617 "Bind socket to this host. Use `--host 0.0.0.0` to make the application "
616618 "available on your local network. IPv6 addresses are supported, for "
617619 "example: --host `'::'`. Uses value in config by default."
618620 ),
619621 ),
620- port : int = typer .Option (
622+ port : Optional [ int ] = typer .Option (
621623 None , help = "Bind to a socket with this port. Uses value in config by default."
622624 ),
623625 scalable : bool = typer .Option (
@@ -659,11 +661,7 @@ def serve_config(
659661
660662 # Delay this import so that we can fail faster if config-parsing fails above.
661663
662- from ..server .app import (
663- build_app_from_config ,
664- logger ,
665- print_admin_api_key_if_generated ,
666- )
664+ from ..server .app import build_app_from_config , logger , print_server_info
667665
668666 # Extract config for uvicorn.
669667 uvicorn_kwargs = parsed_config .pop ("uvicorn" , {})
@@ -684,8 +682,11 @@ def serve_config(
684682 web_app = build_app_from_config (
685683 parsed_config , source_filepath = config_path , scalable = scalable
686684 )
687- print_admin_api_key_if_generated (
688- web_app , host = uvicorn_kwargs ["host" ], port = uvicorn_kwargs ["port" ]
685+ print_server_info (
686+ web_app ,
687+ host = uvicorn_kwargs ["host" ],
688+ port = uvicorn_kwargs ["port" ],
689+ include_api_key = api_key is None ,
689690 )
690691
691692 # Likewise, delay this import.
0 commit comments