flask

How To Have Django Packages in Flask

Django packages in Flask seems like a far-away dream, but shopyo 4.6.0 allows you to install Shopyo apps from pypi. What is Shopyo? Shopyo implements Django functionalities such as the admin panel etc by using existing Flask packages. But, it also implements Django-specifics like the collectstatic command, migrations, apps, even new concepts like boxes etc. …

How To Have Django Packages in Flask Read More »

How to integrate P5JS with Flask-SocketIO

P5Js is an implementation of processing.org’s library in JavaSript. It can be thought of as a canvas management library. Integrating such a library with a common backend like Flask unlocks amazing opportunities. Canvas is even better if sockets.io is involved for real-time events. This post shows how to integrate these 3 libraries using flask-socketio. Main …

How to integrate P5JS with Flask-SocketIO Read More »

Build A Note App In Flask As Fast As It Can Get (Using Shopyo)

Shopyo is a framework to get started with Flask really quick. It includes several libraries to get started by default. In this tutorial we will build a simple app to get started with. We used it for FlaskCon 2021 [site, codebase]. First steps The first step is to install the library. python3.9 -m venv venv …

Build A Note App In Flask As Fast As It Can Get (Using Shopyo) Read More »

How to Integrate Tinymce 5 with Flask (with csrf)

This article shows how to integrate Tinymce 5 with Flask even including csrf protection! Text area <textarea id=”content”></textarea> Tinymce <script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/tinymce/5.10.2/tinymce.min.js”></script> <script type=”text/javascript”> tinymce.init({ selector: ‘#content’, plugins: [ ‘advlist autolink link image imagetools lists charmap print preview hr anchor pagebreak spellchecker’, ‘searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking’, ‘save table contextmenu directionality …

How to Integrate Tinymce 5 with Flask (with csrf) Read More »

Learning Flask To Help With Dog Care: Interview With Chris Hopkinson

Chris has been learning Flask to help with Dog Care. He felt Flask would help him in his business activities! Let’s have a chat with him! Welcome Chris Hopkinson, Can you present yourself, your business? While I have a background in computing, programming, and web development, I have been away from the scene for almost …

Learning Flask To Help With Dog Care: Interview With Chris Hopkinson Read More »

How to implement beautiful notifications in Flask

Since you already know how to implement notifications, let’s see how to implement beautiful notifications in Flask. Using boostrap, we can do: # shopyoapi.html def notify(message, alert_type=”primary”): “”” Used with flash flash(notify(‘blabla’)) Parameters ———- message: str message to be displayed alert_type: str bootstrap class Returns ——- None “”” alert = “”” <div class=”shopyo-alert alert alert-{alert_type} …

How to implement beautiful notifications in Flask Read More »

How to prevent the Open Redirect vulnerability with the next parameter in Flask

Let’s say someone codes a url like this: http://domain.com/do/something?next=http://domain.com/homepage Now an attacker can craft the url like that: http://domain.com/do/something?next=http://evildomain.com/homepage If you don’t sanitise the next, your user will be taken to the evil site. This is the Open Redirect vulnerability. That’s why you must make sure urls are safe. You do it like that: from …

How to prevent the Open Redirect vulnerability with the next parameter in Flask Read More »

How to disable csrf protection for particular routes in Flask-wtf

Flask-wtf recommends using @csrf.exempt to disable csrf protection for particular routes as in the case of APIs. Now this is pretty confusing. What does csrf refers to? If you inspect Flask-wtf you do see a csrf attribute >>> import flask_wtf >>> dir(flask_wtf) [‘CSRFProtect’, ‘CsrfProtect’, ‘FlaskForm’, ‘Form’, ‘Recaptcha’, ‘RecaptchaField’, ‘RecaptchaWidget’, ‘__builtins__’, ‘__cached__’, ‘__doc__’, ‘__file__’, ‘__loader__’, ‘__name__’, …

How to disable csrf protection for particular routes in Flask-wtf Read More »

How to correctly use the next parameter in login and logout in Flask

Here is a sample login and logout route taken from the shopyo web framework. You can learn here how is get_safe_redirect defined and why it is important @auth_blueprint.route(“/login”, methods=[“GET”, “POST”]) def login(): context = {} login_form = LoginForm() context[“form”] = login_form if login_form.validate_on_submit(): email = login_form.email.data password = login_form.password.data user = User.query.filter( func.lower(User.email) == func.lower(email) …

How to correctly use the next parameter in login and logout in Flask Read More »

How to run a Flask Linux-only App on Windows – The AFPy Site

There are in the Python world many Flask Linux-only apps. However in many case, with some twerking we can make them work on Windows. We’ll take the case of the AFPy site. First fork the AFPy site Then clone it git clone https://github.com/<your-username>/site.git The makefile looks like this VENV = $(PWD)/.env PIP = $(VENV)/bin/pip PYTHON …

How to run a Flask Linux-only App on Windows – The AFPy Site Read More »