Hackforge Academy

Category: python

query parameters and form data

Published on 30 Sep 2026

Explanation

Query parameters are values provided after the ? in a URL.

Code:

GET /users?page=2&size=10

Explanation

Use request.args.get() to retrieve query parameters.

Code:

@app.route('/users')
def users():
    page = request.args.get('page', 1, type=int)
    size = request.args.get('size', 10, type=int)
    return {'page': page, 'size': size}

Explanation

Form data submitted using application/x-www-form-urlencoded can be accessed through request.form.

Code:

@app.route('/login', methods=['POST'])
def login():
    username = request.form.get('username')
    password = request.form.get('password')
    return {'username': username}

Explanation

HTML forms send named fields to the Flask endpoint specified in the action attribute.

Code:

<form action="/login" method="post">
    <input name="username">
    <input name="password" type="password">
    <button>Login</button>
</form>

Explanation

Query parameters and form data are different request locations and are accessed using different Flask APIs.

Code:

request.args
β†’ Query Parameters

request.form
β†’ Form Data

request.get json()
β†’ JSON Body

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community