π₯ Flask Flashcards
π‘ What is Flask?
A lightweight WSGI web application framework in Python that’s easy to extend and simple to use.
π Is Flask asynchronous?
Flask itself is synchronous, but you can integrate it with asyncio or use frameworks like Quart for async support.
π¦ How do you install Flask?
Use
pip install Flask
to install Flask via pip.π What is a Flask route?
A URL pattern defined in your app using the
@app.route()
decorator to bind functions to URLs.ποΈ How to handle templates?
Flask uses Jinja2 templating engine to render HTML files from a ‘templates’ folder.
π How to manage sessions?
Flask provides a secure session object stored in cookies, using a secret key.
π§ͺ How to test a Flask app?
Use Flaskβs built-in test client along with pytest or unittest for integration and unit testing.
π Can Flask build APIs?
Yes, Flask is commonly used to build REST APIs using routes and JSON responses.
π How to enable CORS?
Use the
flask-cors
extension to allow cross-origin requests.π Where are static files stored?
In a folder named
static
within your Flask project; accessible via url_for('static', ...)
.