
Domains
Agile Management
Master Agile methodologies for efficient and timely project delivery.
View All Agile Management Coursesicon-refresh-cwCertifications
Scrum Alliance
16 Hours
Best Seller
Certified ScrumMaster (CSM) CertificationScrum Alliance
16 Hours
Best Seller
Certified Scrum Product Owner (CSPO) CertificationScaled Agile
16 Hours
Trending
Leading SAFe 6.0 CertificationScrum.org
16 Hours
Professional Scrum Master (PSM) CertificationScaled Agile
16 Hours
SAFe 6.0 Scrum Master (SSM) CertificationAdvanced Certifications
Scaled Agile, Inc.
32 Hours
Recommended
Implementing SAFe 6.0 (SPC) CertificationScaled Agile, Inc.
24 Hours
SAFe 6.0 Release Train Engineer (RTE) CertificationScaled Agile, Inc.
16 Hours
Trending
SAFe® 6.0 Product Owner/Product Manager (POPM)IC Agile
24 Hours
ICP Agile Certified Coaching (ICP-ACC)Scrum.org
16 Hours
Professional Scrum Product Owner I (PSPO I) TrainingMasters
32 Hours
Trending
Agile Management Master's Program32 Hours
Agile Excellence Master's ProgramOn-Demand Courses
Agile and ScrumRoles
Scrum MasterTech Courses and Bootcamps
Full Stack Developer BootcampAccreditation Bodies
Scrum AllianceTop Resources
Scrum TutorialProject Management
Gain expert skills to lead projects to success and timely completion.
View All Project Management Coursesicon-standCertifications
PMI
36 Hours
Best Seller
Project Management Professional (PMP) CertificationAxelos
32 Hours
PRINCE2 Foundation & Practitioner CertificationAxelos
16 Hours
PRINCE2 Foundation CertificationAxelos
16 Hours
PRINCE2 Practitioner CertificationSkills
Change ManagementMasters
Job Oriented
45 Hours
Trending
Project Management Master's ProgramUniversity Programs
45 Hours
Trending
Project Management Master's ProgramOn-Demand Courses
PRINCE2 Practitioner CourseRoles
Project ManagerAccreditation Bodies
PMITop Resources
Theories of MotivationCloud Computing
Learn to harness the cloud to deliver computing resources efficiently.
View All Cloud Computing Coursesicon-cloud-snowingCertifications
AWS
32 Hours
Best Seller
AWS Certified Solutions Architect - AssociateAWS
32 Hours
AWS Cloud Practitioner CertificationAWS
24 Hours
AWS DevOps CertificationMicrosoft
16 Hours
Azure Fundamentals CertificationMicrosoft
24 Hours
Best Seller
Azure Administrator CertificationMicrosoft
45 Hours
Recommended
Azure Data Engineer CertificationMicrosoft
32 Hours
Azure Solution Architect CertificationMicrosoft
40 Hours
Azure DevOps CertificationAWS
24 Hours
Systems Operations on AWS Certification TrainingAWS
24 Hours
Developing on AWSMasters
Job Oriented
48 Hours
New
AWS Cloud Architect Masters ProgramBootcamps
Career Kickstarter
100 Hours
Trending
Cloud Engineer BootcampRoles
Cloud EngineerOn-Demand Courses
AWS Certified Developer Associate - Complete GuideAuthorized Partners of
AWSTop Resources
Scrum TutorialIT Service Management
Understand how to plan, design, and optimize IT services efficiently.
View All DevOps Coursesicon-git-commitCertifications
Axelos
16 Hours
Best Seller
ITIL 4 Foundation CertificationAxelos
16 Hours
ITIL Practitioner CertificationPeopleCert
16 Hours
ISO 14001 Foundation CertificationPeopleCert
16 Hours
ISO 20000 CertificationPeopleCert
24 Hours
ISO 27000 Foundation CertificationAxelos
24 Hours
ITIL 4 Specialist: Create, Deliver and Support TrainingAxelos
24 Hours
ITIL 4 Specialist: Drive Stakeholder Value TrainingAxelos
16 Hours
ITIL 4 Strategist Direct, Plan and Improve TrainingOn-Demand Courses
ITIL 4 Specialist: Create, Deliver and Support ExamTop Resources
ITIL Practice TestData Science
Unlock valuable insights from data with advanced analytics.
View All Data Science Coursesicon-dataBootcamps
Job Oriented
6 Months
Trending
Data Science BootcampJob Oriented
289 Hours
Data Engineer BootcampJob Oriented
6 Months
Data Analyst BootcampJob Oriented
288 Hours
New
AI Engineer BootcampSkills
Data Science with PythonRoles
Data ScientistOn-Demand Courses
Data Analysis Using ExcelTop Resources
Machine Learning TutorialDevOps
Automate and streamline the delivery of products and services.
View All DevOps Coursesicon-terminal-squareCertifications
DevOps Institute
16 Hours
Best Seller
DevOps Foundation CertificationCNCF
32 Hours
New
Certified Kubernetes AdministratorDevops Institute
16 Hours
Devops LeaderSkills
KubernetesRoles
DevOps EngineerOn-Demand Courses
CI/CD with Jenkins XGlobal Accreditations
DevOps InstituteTop Resources
Top DevOps ProjectsBI And Visualization
Understand how to transform data into actionable, measurable insights.
View All BI And Visualization Coursesicon-microscopeBI and Visualization Tools
Certification
24 Hours
Recommended
Tableau CertificationCertification
24 Hours
Data Visualization with Tableau CertificationMicrosoft
24 Hours
Best Seller
Microsoft Power BI CertificationTIBCO
36 Hours
TIBCO Spotfire TrainingCertification
30 Hours
Data Visualization with QlikView CertificationCertification
16 Hours
Sisense BI CertificationOn-Demand Courses
Data Visualization Using Tableau TrainingTop Resources
Python Data Viz LibsCyber Security
Understand how to protect data and systems from threats or disasters.
View All Cyber Security Coursesicon-refresh-cwCertifications
CompTIA
40 Hours
Best Seller
CompTIA Security+EC-Council
40 Hours
Certified Ethical Hacker (CEH v12) CertificationISACA
22 Hours
Certified Information Systems Auditor (CISA) CertificationISACA
40 Hours
Certified Information Security Manager (CISM) Certification(ISC)²
40 Hours
Certified Information Systems Security Professional (CISSP)(ISC)²
40 Hours
Certified Cloud Security Professional (CCSP) Certification16 Hours
Certified Information Privacy Professional - Europe (CIPP-E) CertificationISACA
16 Hours
COBIT5 Foundation16 Hours
Payment Card Industry Security Standards (PCI-DSS) CertificationOn-Demand Courses
CISSPTop Resources
Laptops for IT SecurityWeb Development
Learn to create user-friendly, fast, and dynamic web applications.
View All Web Development Coursesicon-codeBootcamps
Career Kickstarter
6 Months
Best Seller
Full-Stack Developer BootcampJob Oriented
3 Months
Best Seller
UI/UX Design BootcampEnterprise Recommended
6 Months
Java Full Stack Developer BootcampCareer Kickstarter
490+ Hours
Front-End Development BootcampCareer Accelerator
4 Months
Backend Development Bootcamp (Node JS)Skills
ReactOn-Demand Courses
Angular TrainingTop Resources
Top HTML ProjectsBlockchain
Understand how transactions and databases work in blockchain technology.
View All Blockchain Coursesicon-stop-squareBlockchain Certifications
40 Hours
Blockchain Professional Certification32 Hours
Blockchain Solutions Architect Certification32 Hours
Blockchain Security Engineer Certification24 Hours
Blockchain Quality Engineer Certification5+ Hours
Blockchain 101 CertificationOn-Demand Courses
NFT Essentials 101: A Beginner's GuideTop Resources
Blockchain Interview QsProgramming
Learn to code efficiently and design software that solves problems.
View All Programming Coursesicon-codeSkills
Python CertificationInterview Prep
Career Accelerator
3 Months
Software Engineer Interview PrepOn-Demand Courses
Data Structures and Algorithms with JavaScriptTop Resources
Python TutorialWeb Development
4.5 Rating 20 Questions 40 mins read12 Readers

The “micro” means Flask aims to keep the core features simple but extensible. It is classified as a micro web framework because it does not require particular tools or libraries. It does not mean that our whole web application has to fit into a single Python module, nor does it imply that Flask is lacking some functionality. Although, it does not support database abstraction layer, form validation, or any other pre-existing third-party tools. But it supports extensions to which we can add features to our applications.
Expect to come across this popular question in Python Flask interview questions.
Flask Python comes with all the advantages of Python. Some of them are listed down below:
In Flask web applications, in order to manipulate databases, we can use SQL and Object Relational Mapping (ORM). An ORM makes writing SQL queries easier for a programmer, because it enables us to write queries in an object-oriented language, and then ORM automatically translates it to SQL and retrieves the result as an object. On the other hand, Flask-User makes use of DbAdapters to support different databases. It ships with an SQLDbAdapter to support a wide range of SQL databases via Flask-SQLAlchemy (Firebird, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, SQLite, Sybase, and more). It ships with a MongoDbAdapter to support MongoDB databases via Flask-MongoEngine. Custom DbAdapters can be implemented to support other Databases.
Flask | Django |
| Flask is a Python web framework built for rapid development | Django is built for easy and simple projects |
| Beginners are likely to find Flask more straightforward and convenient | Django is a high-level Python Framework- when compared to Flask, it comes with a slightly steeper learning curve. Experienced developers might enjoy working with Django and understand its architecture and conventions are better |
| Flask is a lightweight framework that gives abundant features without external libraries and minimalist features | Django is a full-stack web framework that enables ready-to-use solutions with its batteries-included approach |
| Flask provides support for API | Django doesn’t have any support for API |
| Flask does not support dynamic HTML pages | Django offers dynamic HTML pages |
| Flask is a WSGI framework | Django is a Full Stack Web Framework |
| Flask offers a diversified working style | Django offers a Monolithic working style |
To deploy the python flask app on Heroku, follow the procedures outlined below:
Create a virtual environment with pipenv and install Flask and Gunicorn by running the command - $ pipenv install
Create a “Procfile” and write the following code - $ touch Procfile flask gunicorn
Create “runtime.txt” and write the following code - $ touch runtime.txt
Create a folder named “app” and enter the folder - $ mkdir app, $ cd app
Create a python file, “main.py” and enter the sample code - $ touch main.py
Get back to the previous directory “eflask”.Create a file“wsgi.py” and insert the following code - $ cd ../ , $ touch wsgi.py
Run the virtual environment - $ pipenv shell
Initialize an empty repo, add the files in the repo and commit all the changes - $ git init, $ git add
$ git commit -m "Initial Commit"
Login to heroku CLI using - heroku login
Now, Create a unique name for your Web app - $ heroku create eflask-app
Push your code from local to the heroku remote
$ git push heroku main
This question is a regular feature in interview questions on Flask, be ready to tackle it.
Flask makes it simple to manage uploaded files. Just remember to include the enctype="multipart/form-data" tag in your HTML form, or the browser will refuse to send your files. Uploaded files are kept in memory or on the filesystem in a temporary place. You may get to those files by looking at the request object's files attribute. Each file that is uploaded is saved in that dictionary. It has the same behavior as a typical Python file object, but it additionally provides a save() method that allows you to save the file to the server's filesystem. Here's a simple example to demonstrate how it works:
from flask import request[Text Wrapping Break][Text Wrapping Break]@app.route('/upload', methods=['GET', 'POST'])[Text Wrapping Break]def upload_file():[Text Wrapping Break] if request.method == 'POST':[Text Wrapping Break] f = request.files['the_file'][Text Wrapping Break] f.save('/var/www/uploads/uploaded_file.txt')The filename attribute can be used to determine how the file was named on the client before it was uploaded to your application. However, keep in mind that its value might be faked, so don't put your faith in it. If you wish to utilize the client's filename to store the file on the server, you can use the secure filename() function that Werkzeug provides:
from werkzeug.utils import secure_filename[Text Wrapping Break][Text Wrapping Break]@app.route('/upload', methods=['GET', 'POST'])[Text Wrapping Break]def upload_file():[Text Wrapping Break] if request.method == 'POST':[Text Wrapping Break] file = request.files['the_file'][Text Wrapping Break] file.save(f"/var/www/uploads/{secure_filename(file.filename)}")Expect to come across this popular question in interview questions on Flask.
You can find yourself in a position where you're dealing with data that should be correct but isn't. For example, you might have some client-side code that sends a faulty HTTP request to the server. This could be due to tampering with the data by a user or a bug in the client code. In most cases, responding with 400 Bad Request is sufficient, but this isn't always the case, and the code must continue to function.
You might still wish to note that something unusual occurred. Loggers come in handy in this situation. With Flask 0.3, you can utilize a logger that has been preconfigured for you.
The following are some examples of log calls:
app.logger.debug('A value for debugging')[Text Wrapping Break]app.logger.warning('A warning occurred (%d apples)', 42)[Text Wrapping Break]app.logger.error('An error occurred')To protect against injection attacks, any user-provided values rendered in the output must be enclosed when returning HTML (the default response type in Flask). This will be done automatically using HTML templates produced with Jinja.
The escape() function, which is seen below, can be used manually. Most examples remove it for brevity's sake, but you should constantly be conscious of how you're employing untrustworthy data.
from markupsafe import escape[Text Wrapping Break][Text Wrapping Break]@app.route("/<name>")[Text Wrapping Break]def hello(name):[Text Wrapping Break] return f"Hello, {escape(name)}!"If a user enters the name <script>alert("bad")</script>, it is rendered as text rather than running the script in the user's browser due to escaping.
We use the url_for() function to create a URL for a given function. It takes the function's name as the first parameter, as well as any number of keyword arguments, each of which corresponds to a variable component of the URL rule. As query parameters, unknown variable bits are appended to the URL.