From the course: Building RESTful APIs with Flask

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

URL parameters

URL parameters

From the course: Building RESTful APIs with Flask

Start my 1-month free trial

URL parameters

- [Bruce] GET requests can do more than just get a simple address. They can also pass data to the server for processing your request, allowing you to present dynamic content to your users based on the URL parameters passed in. Consider this URL, it's a very simple URL with no parameters on it. We can add parameters to the end by adding a question mark followed by a series of key-value pairs. This allows your front-end to pass in variable information directly to your endpoint. Let's look at how to support parameters on our endpoint URLs. Back in Pycharm I'll add my new route which I'll call parameters. I'm going to do that at line 19. I'll just add a couple of spaces here and I'll add my definition. You don't have to do anything special in the endpoint definition. The magic happens inside the decorated function. So I'll create my function definition. And inside the function body I'll create two normal Python variables. In each case I'll reference the request object followed by the…

Contents