angle-up arrow-clockwise arrow-counterclockwise arrow-down-up arrow-left at calendar card-list chat check envelope folder house info-circle pencil people person person-plus phone plus question-circle search tag trash x
30 January 2020 Updated 30 January 2020 by Peter
post main image
When you start with Flask you read a bit about the Application Context, TL;DR. Do not know about you but I certainly did not understand it fully. What is app, what is current_app, what is the difference, you just start programming your application. All the time in the background there is this weird buzz: what exactly is the Application Context ... Then at a certain moment when using a class you instantiated ...
Read more
24 January 2020 Updated 24 January 2020 by Peter
post main image
When you sign up for this website you are assigned an avatar image. Of course you can change the avatar in 'your account' and this is done using an image picker. Many image pickers examples can be found on the internet. But this is a Flask site including WTForms and I want the image picker to be generated by the wonderful Jinja macro I am using, see also link below, ok, I modified it a bit. With this ...
Read more
13 January 2020 Updated 13 January 2020 by Peter
post main image
Time for joy or crisis: running the OWASP Zed Attack Proxy (ZAP) application to check vulnerabilities of our web application. Developers often know there are weak points in their code, but there always is a date of delivery. So why not use a tool that list the well-known and  important ones? This is my first time using ZAP so if are an expert you best stop reading here. In the links below there ...
Read more
6 January 2020 Updated 9 January 2020 by Peter
post main image
This Flask website is multilanguage. The implementation is described in previous posts. So far all my translations were in the Python code and the HTML templates. On a few places I needed some translations in Javascript and did this by pulling this Javascript code inline in the HTML template. For example, for forms I needed: e.target.setCustomValidity('Please fill out this field.'); I ...
Read more
27 December 2019 Updated 27 December 2019 by Peter
post main image
You created a Flask web application, it is running fine and using https. But is it secure enough? Did you do everything to protect your visitors, did you do everything to prevent malicious attacks? A good way to proceed on this is to pentest your site. Penetration testing tools, or pen testing tools, can identifying security weaknesses. They identify vulnerabilities in the web application that can ...
Read more
9 December 2019 by Peter
post main image
Again another unexpected Docker issue. In a previous post I described why and how you must force Docker to use a subnet, to prevent sudden unexpected changes in the network with consequences like mail no longer working. This post is about Docker not respecting firewall settings, at least when running Debian / Ubuntu and ufw (Uncomplicated Firewall). Docker does not tell you this, and exposes ports, ...
Read more
27 November 2019 Updated 27 November 2019 by Peter
post main image
I have an ISPConfig server with Docker applications. They use the host Postfix mail transfer agent (MTA) to deliver mail to the outside world. Before using the send mail function I have a check if Postfix can be accessed. This works fine. But suddenly mail was not sent. The log file contained error messages like: 2019-11-26 17:31:56,758 ERROR MailMessage - send_mail: self.error_message = sending message, ...
Read more
24 November 2019 Updated 24 November 2019 by Peter
post main image
For this website I am using Flask and SQLAlchemy without the Flask-SQLAlchemy extension. I need pagination for several pages. For example the home page holds the list of blogs and it should show a maximum of 12 items per page. It is not that difficult to implement. The home page view function requires a page_number that defaults to 1 if it not specified: @pages_blueprint.route('/', defaults={'page_number': ...
Read more
18 November 2019 Updated 19 November 2019 by Peter
post main image
Probably many of you know only two mobile phone operating systems, iOS on Apple phones, and Googles Android on all other phones (some 80%). But there is also Ubuntu Touch (UT) originally developed by Canonical Ltd. and continued by UBports. I write a post about this because I am using UT on a Nexus 5 and wondered how difficult it would be to develop apps for it. When I discovered that you can use Python ...
Read more
13 November 2019 by Peter
post main image
While writing an application on my Docker platform I hit an unexpected problem, yes, another one ... This was the first time that I had to show the time on a page of a website running on Docker and it appeared that the time was UTC instead of local time. In the code I was just using the normal Python calls to get the time: import datetime ... now = datetime.datetime.now() hour = now.hour ...
Read more