Deploy an Age-Guessing Website
Deploy an Age-Guessing Website
Make a website that guesses people’s ages from their names.
Make a website that guesses people’s ages from their names.
In[]:=
CloudDeploy[FormFunction[{"name","Enter name"}"GivenName",Row[{"You are probably ",#name["MostCommonAge"]," old"}]&,"PNG"],Permissions->"Public"]
Out[]=
Specify the name in a URL query string rather than in a form:
In[]:=
CloudDeploy[APIFunction[{"name""GivenName"},Row[{"You are probably ",#name["MostCommonAge"]," old"}]&,"PNG"],Permissions->"Public"]
Out[]=
How it works
How it works
The “MostCommonAge” predictor for given names is built into the Wolfram Language. It analyzes statistical distributions of ages to determine the most common age for a given name:
In[]:=
=[erin given name]["MostCommonAge"]
Out[]=
Make a website that gives the most common age of a name entered into a form. Click the link in the resulting to visit the website:
In[]:=
form=CloudDeploy[FormFunction[{"name","Enter name"}"GivenName",Row[{"You are probably ",#name["MostCommonAge"]," old"}]&,"PNG"],Permissions->"Public"]
Out[]=
Alternatively, you can make a URL whose query string specifies the name:
In[]:=
api=CloudDeploy[APIFunction[{"name""GivenName"},Row[{"You are probably ",#name["MostCommonAge"]," old"}]&,"PNG"],Permissions->"Public"]
Out[]=
This link visits the URL with the name “Erin”:
In[]:=
Hyperlink[api[[1]]<>"?name=Erin"]