1212import rignore
1313import typer
1414from httpx import Client
15- from pydantic import BaseModel
15+ from pydantic import BaseModel , EmailStr , TypeAdapter , ValidationError
1616from rich .text import Text
1717from rich_toolkit import RichToolkit
1818from rich_toolkit .menu import Option
@@ -385,6 +385,115 @@ def _setup_environment_variables(toolkit: RichToolkit, app_id: str) -> None:
385385 progress .log ("Environment variables set up successfully!" )
386386
387387
388+ class SignupToWaitingList (BaseModel ):
389+ email : EmailStr
390+ name : str | None = None
391+ organization : str | None = None
392+ role : str | None = None
393+ team_size : str | None = None
394+ location : str | None = None
395+ use_case : str | None = None
396+ secret_code : str | None = None
397+
398+
399+ def _send_waitlist_form (
400+ result : SignupToWaitingList ,
401+ toolkit : RichToolkit ,
402+ ) -> None :
403+ with toolkit .progress ("Sending your request..." ) as progress :
404+ with APIClient () as client :
405+ with handle_http_errors (progress ):
406+ response = client .post (
407+ "/users/waiting-list" ,
408+ json = result .model_dump (mode = "json" ),
409+ )
410+
411+ response .raise_for_status ()
412+
413+ progress .log ("Request sent successfully!" )
414+
415+
416+ def _waitlist_form (toolkit : RichToolkit ) -> None :
417+ from rich_toolkit .form import Form
418+
419+ toolkit .print (
420+ "We're currently in private beta. If you want to be notified when we launch, please fill out the form below." ,
421+ tag = "waitlist" ,
422+ )
423+
424+ toolkit .print_line ()
425+
426+ email = toolkit .input (
427+ "Enter your email:" ,
428+ required = True ,
429+ validator = TypeAdapter (EmailStr ),
430+ )
431+
432+ toolkit .print_line ()
433+
434+ result = SignupToWaitingList (email = email )
435+
436+ if toolkit .confirm (
437+ "Do you want to get access faster by giving us more information?" ,
438+ tag = "waitlist" ,
439+ ):
440+ toolkit .print_line ()
441+ form = Form ("Waitlist form" , style = toolkit .style )
442+
443+ form .add_input ("name" , label = "Name" , placeholder = "John Doe" )
444+ form .add_input ("organization" , label = "Organization" , placeholder = "Acme Inc." )
445+ form .add_input ("team" , label = "Team" , placeholder = "Team A" )
446+ form .add_input ("role" , label = "Role" , placeholder = "Developer" )
447+ form .add_input ("location" , label = "Location" , placeholder = "San Francisco" )
448+ form .add_input (
449+ "how_do_you_plan_to_use_fastapi_cloud" ,
450+ label = "How do you plan to use FastAPI Cloud?" ,
451+ placeholder = "I'm building a web app" ,
452+ )
453+ form .add_input ("secret_code" , label = "Secret code" , placeholder = "123456" )
454+
455+ result = form .run ()
456+
457+ try :
458+ result = SignupToWaitingList .model_validate (
459+ {
460+ "email" : email ,
461+ ** result ,
462+ }
463+ )
464+ except ValidationError :
465+ toolkit .print (
466+ "[error]Invalid form data. Please try again.[/]" ,
467+ )
468+
469+ return
470+
471+ toolkit .print_line ()
472+
473+ if toolkit .confirm (
474+ (
475+ "Do you agree to\n "
476+ "- Terms of Service: [link=https://fastapicloud.com/legal/terms]https://fastapicloud.com/legal/terms[/link]\n "
477+ "- Privacy Policy: [link=https://fastapicloud.com/legal/privacy-policy]https://fastapicloud.com/legal/privacy-policy[/link]\n "
478+ ),
479+ tag = "terms" ,
480+ ):
481+ toolkit .print_line ()
482+
483+ _send_waitlist_form (
484+ result ,
485+ toolkit ,
486+ )
487+
488+ import os
489+
490+ os .system ("open raycast://confetti" )
491+
492+ toolkit .print_line ()
493+
494+ toolkit .print ("Thank you for your interest in FastAPI Cloud! 🚀" )
495+
496+
388497def deploy (
389498 path : Annotated [
390499 Union [Path , None ],
@@ -401,17 +510,14 @@ def deploy(
401510 """
402511
403512 with get_rich_toolkit () as toolkit :
404- toolkit .print_title ("Starting deployment" , tag = "FastAPI" )
405- toolkit .print_line ()
406-
407513 if not is_logged_in ():
408- toolkit .print (
409- "No credentials found. Use [blue]`fastapi login`[/] to login." ,
410- tag = "auth" ,
411- )
514+ _waitlist_form (toolkit )
412515
413516 raise typer .Exit (1 )
414517
518+ toolkit .print_title ("Starting deployment" , tag = "FastAPI" )
519+ toolkit .print_line ()
520+
415521 path_to_deploy = path or Path .cwd ()
416522
417523 app_config = get_app_config (path_to_deploy )
0 commit comments