Loading

Quipoin Menu

Learn • Practice • Grow

python / Flask Basics
interview

Q1. What is Flask?
Flask is a lightweight WSGI web application framework in Python. It is designed to be simple and extensible, with a small core but many extensions for added functionality. It's popular for building REST APIs and web applications.

Q2. How do you create a minimal Flask app?
Example:
from flask import Flask app = Flask(__name__) @app.route(''/'') def hello(): return ''Hello, World!'' if __name__ == ''__main__'': app.run()

Q3. What are routes and how do you handle URL parameters?
Routes are defined using @app.route(). You can capture URL parameters with . Example:
@app.route(''/user/'') def user(name): return f''Hello {name}''
You can also specify types: /user/.

Q4. How do you handle POST requests and form data?
Use request object from flask. Example:
from flask import request @app.route(''/submit'', methods=[''POST'']) def submit(): name = request.form[''name''] return f''Received {name}''
For JSON, use request.get_json().

Q5. What is template rendering in Flask?
Flask uses Jinja2 templating. Create HTML files in a templates folder, then use render_template(). Example:
from flask import render_template @app.route(''/profile/'') def profile(name): return render_template(''profile.html'', name=name)