title: How can i pass my url parameters as variables in a RESTful API using Python
body: <p>I have written the back-end code to retrieve information from an existing API that passes in three inputs (attribute1, attribute2, and API_key) to return a JSON document.</p>
  
  <p>Now, I am trying to use the web.py module to connect to a server on port 8080 using Python. I am designing a RESTful API and I want to take in the parameters that a user types into the URL, and pass those as arguments into the above function to return the JSON document.</p>
  
  <p>This is my simple web server code.</p>
  
  <pre><code>import web
  import existing_api
  
  attribute1 = ' '
  attribute2 = ' '
  api_key = ' '
  url = ('/existingapi/'+attribute1+'/'+attribute2+'/'+api_key, 'index')
  #print url
  class index:
      def GET(self):
          return existing_api.retrieveInfo(attribute1, attribute2, api_key)
  
  
  if __name__ == '__main__':
      app = web.application(url, globals())
      app.run()
  </code></pre>
  
  <p>I have written my back-end code in existing_api.py and I would like for a user to be able to enter "localhost:8080/:attribute1/:attribute2/:api_key" 
  into the browser and return existing_api.retrieveInfo(attribute1, attribute2, api_key). What is the best approach to do this? </p>
  
  <p>Also, when I try to hardcode the attributes and api_key, the URL returns a "not found" message. However, if I change the code for the url: </p>
  
  <pre><code>url = ('/existingapi/'+attribute1+'/'+attribute2+'/'+api_key, 'index')
  </code></pre>
  
  <p>to read</p>
  
  <pre><code>url = ('/', 'index')    
  </code></pre>
  
  <p>without the attributes and type in localhost:8080, I receive the information I am looking for from the hardcoded attributes. Can anyone explain why this is the case? Thanks.</p>