Python has some built-in modules for sending emails. Typically we would use smtplib and email modules. email module can build email structure and layout, while smtplib can use and call smtp servers to send emails. email module has many usefull classes: MIMEMultipart: content-type header identifier, marks the position and function of the current paragraph in an email, results in something like this Content-Type: multipart/related; boundary="===============4225807650688820451==". MIMEText: render data into messages, can be plain or html and will become something like this Content-Type: text/html; charset="us-ascii" in a message.

Continue reading

Python Hints

Pip dependency failure Sometimes when install pip package it may result in dependency failure: Downloading/unpacking cffi>=1.4.1 (from cryptography>=1.7->pyOpenSSL>=0.14->pyvmomi) Running setup.py (path:/tmp/pip_build_root/cffi/setup.py) egg_info for package cffi unable to execute 'x86_64-linux-gnu-gcc': No such file or directory unable to execute 'x86_64-linux-gnu-gcc': No such file or directory No working compiler found, or bogus compiler options passed to the compiler from Python's distutils module. See the error messages above. (If they are about -mno-fused-madd and you are on OS/X 10.

Continue reading

Flask

INTRODUCTION To begin: sudo pip install flask I’m assuming you already know the basics of REST. If not, or if you want a quick refresh, I’ve written an introduction to Designing a RESTful Web API. Flask is a microframework for Python based on Werkzeug, a WSGI utility library. Flask is a good choice for a REST API because it is: Written in Python (that can be an advantage); Simple to use; Flexible; Multiple good deployment options; RESTful request dispatching I normally use curl to make test requests and there’s a curl mini-reference at the end of this article.

Continue reading

Author's picture

LuLU

Love coding and new technologies

Cloud Solution Consultant

Canada