Flask Interview Questions and Answers
Ques 6. How to add an emailing function in Flask?
Yes, we can add an emailing function in the Flask framework. Actually, we need to install the Flask-Mail extension. We can use the given below command:
Pip install Flask-Mail
Now, after installation, we need to go to the Flask Config API. Under config, we will get Mail-Server, Mail_Port, Mail_username, Mail_Password, etc options. We can use the mail.send() method to compose the message.
from flask_mail import Mail,Message
from flask import Flaskapp=Flask(_name_)
mail=Mail(app)
@app.route(\"/mail\")
def email():
Msg=Message(\"Hello Message\",Sender=\"admin@test.com\",recipients=[\"to@test.com\"])
Mail.send(msg)
Ques 7. What is WSGI?
The full form of WSGI is Web Server Gateway Interface. This is actually a Python standard in PEP 3333. It provides the protocol for web servers to communicate with a web application.
It mainly plays a role at the time of project deployment.
Ques 8. What is the default local host and port in Flask?
The default Flask local host is 127.0.0.1 and the default port is 5000.
Ques 9. What is Flask-wtf?
It provides an easy integration process with WTForms.
Ques 10. What features are available in Flask-wtf?
A few features are as follows:
- Integration with WTForms.
- CSRF token provides security globally.
- Provide Recaptcha.
- File upload facility.
Most helpful rated by users: