Open live version
Find the Population of a Country
Create a web form to find the population of a country.
code
CloudDeploy[
FormFunction[{{"x", "Find the population of this country:"} ->
"ComputedCountry"}, CountryData[#x, "Population"] &],
Permissions -> "Public"]
how it works
This example was live-coded at the Wolfram Research booth at SXSW, March 9, 2014.
This gives the population of the United States:
CountryData["UnitedStates", "Population"]
The country known to the Wolfram Language as “UnitedStates” is known by many other names. An Interpreter object will translate from natural language names to the Wolfram Language name:
Interpreter["ComputedCountry"] /@ {"US", "usa", "u.s.a.", "America"}
With those two functionalities, you can make a web form that gives the population of a country you specify. The “ComputedCountry” Interpreter is used automatically to determine the country from what is entered in the form. Specify Permissions->”Public” to make the form accessible to everyone:
CloudDeploy[
FormFunction[{{"x", "Find the population of this country:"} ->
"ComputedCountry"}, CountryData[#x, "Population"] &],
Permissions -> "Public"]