skFla Flashcards
What is the default host port and port of Flask?
localhost (127.0.0.1), and the default port is 5000
How to change default host and port in Flask?
app.run(host=”0.0.0.0”, port=8080)
what are some Flask commands?
sdfsfdsf
request object in Flask
@app.route("/") def index(): val = request.args.get("var")
How to get the user agent in Flask
@app.route("/") def index(): user_agent = request.headers.get('User-Agent')
How to use url_for in the Flask application?
Flask’s url_for function helps in creating dynamic routes. We can make use of url_for in the Flask templates.
<a>{{post.title}}</a><a></a>
View function for handling variables in routes
@app.route(“/blog/post/”) def get_post_id(post_id): return post_id
How to create an Admin interface in Flask?
We can create an Admin interface in Flask using the Flask-Admin extension, or the Flask-Appbuilder extension
What does the Flask-Admin extension help with?
grouping views together into classes
Does Flask-Appbuilder already come with an Admin interface?
Yes
Why is Flask called a Microframework?
Flask only provides core features such as request, routing, and blueprints. For other features, such as Caching, ORM, forms, etc., we need to make use of Flask-Extensions
How can we integrate the Twitter API?
To integrate with Flask, we can make use of a Flask extension called Flask-Social. It not only helps in authenticating users from Twitter but also other social platforms or accounts such as Facebook and Google. We need to use Flask-Social along with Flask-Security.
We need to install individual API libraries in Python and also need to get consumer and secret keys by registering the Flask application on the external account providers.
What are some benefits of using the Flask framework?
It has an inbuilt development server. It has vast third-party extensions. It has a tiny API and can be quickly learned by a web developer. It is WSGI compliant. It supports Unicode.
Is the SQLite database built-in Flask?
SQLite is in-built with Python. Inside the view, we can import SQLite and write SQL queries for interacting with the database
What do most Flask devs usually use for SQLite?
Flask-SQLAlchemy, which eliminates the need to write complex SQL queries and is an ORM to interact with the SQLite database