Flask Web Framework

Flask session simplest example

Flask sessions are useful when we want to remember a specific user. For example to know the user already visited the website before. So we can generate dynamic content for that user. Or we can use login based system In this code we will use the simplest flask session example Run the code go the […]

Expiring Links Tutorial: Python Flask One-Time Link Generator

One time links are essential where users want to share resources with co-worker or friend’s effortlessly but at the same time restrict other from access. Its works best because the link automatically inactive if some one go to the link for the first time. That means the same link will not work for the second […]

Create your first chat application with Flask and Socketio

We will use socketio for real-time messaging First install our dependency for this application pip install flask pip install flask-socketio Copy Code How it will work. Every user will get an unique key. If the the other user submit the other users key that will send the message. its like sending message to unique username […]

Ajax example with flask

One of the best ajax applied in real world is username checker. In this example we will check if there is existing username This is code /project we will Our first step: Check if username exists or not Imagine we have this existing username when the user enter a username we will check it from […]

Flask testing environment ssl solution with “adhoc”

Why? When I started developing video calling application at one point I faced this situation. In single pc(on localhost 127.0.0.1) everything works very well but when I need to test another pc on the same network for example(wifi) . Before on public production environment I wanted to test my own private network which was established […]

How to implement json web token (jwt) in flask

What is json web token? JSON Web Token (JWT) is like a digital ID card for websites and apps. It’s often issued after a successful login and securely tells a website about the user and their accessibility Secure Cookies also do the same thing. but there is some core differences Feature JSON Web Token (JWT) […]

Building a Simple and Secure API with Python Flask

Server-Side: Flask API Development We will build a simple API that will tell the current time. And then add more feature. The explanation and the code The code from flask import Flask, request, jsonify from datetime import datetime app = Flask(__name__) # Define a route to get the current time @app.route(‘/get-current-time’, methods=[‘POST’]) def get_current_time(): # […]

Flask File Handling Made Easy: Upload and Download Files

Very basic example code_features This is our first example… Run this code first. Then read the step by step explanation. That will be more effective. Because this tutorial is all about practice. In this article covers simple upload, upload to database, securing the upload by adding limiting file extension and adding download link… Run the […]

How To Generate URL And Route Dynamically In Flask

We can set route dynamically instead of fixed route. For example In the pre-determined route links generate like this example.com/users/profile In the dynamically gendered route will be like this example.com/users/custom_profile_name We will use @app.route(‘/<username>’) The code will be like this We can use anything in the <username> here So if we load page like example.com/anything_here […]

Python Flask : Starter Automated Template

When starting new project again, Some common structure needed to be written again and again. So I wrote a program nearly three years (2021) ago to Get Everything ready on one script. Here is the python script that makes everything ready Here is is the revised version of the code The Program Automatically generates basic […]