URL Template
Encyclopedia
A URL Template is a way to specify a URL that includes parameters that must be substituted before the URL is resolved. The syntax is usually to enclose the parameter in Braces ({example}). The convention is for a parameter to not be Percent encoded unless it follows a Question Mark
(?).
If we were building these urls for Björk
with firstName=Björk and lastName=Guðmundsdóttir they would be:
Note: this will go into an infinite loop if
External links
Question mark
The question mark , is a punctuation mark that replaces the full stop at the end of an interrogative sentence in English and many other languages. The question mark is not used for indirect questions...
(?).
Examples
-
http://example.com/people/{firstName}-{lastName}/SSN -
http://example.com/query?firstName={firstName}&lastName={lastName}
If we were building these urls for Björk
Björk
Björk Guðmundsdóttir , known as Björk , is an Icelandic singer-songwriter. Her eclectic musical style has achieved popular acknowledgement and popularity within many musical genres, such as rock, jazz, electronic dance music, classical and folk...
with firstName=Björk and lastName=Guðmundsdóttir they would be:
-
http://example.com/people/Björk-Guðmundsdóttir/SSN -
http://example.com/query?firstName=Bj%c3%b6rk&lastName=Gu%c3%b0mundsd%c3%b3ttir
Code
In python, if you have the variablename
that you want to put into the string url
, you can simply do this:Note: this will go into an infinite loop if
name "{name}"
or other such corner cases.External links