Tag archive for: Flask

How to use pycrypto, python-qrcode and Flask-RESTPlus to create QR codes that can send encrypted data to an endpoint

If you want to direct someone to a web page without saying a word, then you can use QR codes to do so.

For example, your QR code reader will direct your phone’s browser to visit our home page when you scan the following QR Code:

Techcoil home page QRCode

Given that, you can use QR codes to send HTTP requests to an endpoint of your HTTP server. In addition, you can embed data that you wish to send to the endpoint in the QR codes.

With this in mind, let’s look at how we can use pycrypto, python-qrcode and Flask-RESTPlus to create QR codes that can send encrypted data to an endpoint.

How to solve “No API definition provided” error for Flask-RESTPlus app on Cloud Foundry

When you create an API endpoint that generates a QRCode with Flask-RESTPlus, you may want to deploy it onto Cloud Foundry.

However, when I first tried to do so, I was greeted with a No API definition provided when I accessed the Swagger Api portal page.

qrcodeapp showing No API definition provided

So why is there a “No API definition provided” error for Flask-RESTPlus app on Cloud Foundry?

In case you are facing such a problem, this post discuss how I had managed to solve the “No API definition provided” error for my Flask-RESTPlus app on Cloud Foundry.

How to create an API endpoint that generates a QR Code image, with Python 3 Flask-RESTPlus and python-qrcode

When you have an API endpoint that generates a QR Code image, another device with a QR Code scanner will be able to get the encoded value to perform some action. For example, WhatsApp web generates a QR Code image that encodes a code for WhatsApp app to sign in the user.

So how can you create an API endpoint that generates a QR Code image? With this in mind, let’s look at how we can do so with Python 3 Flask-RESTPlus and python-qrcode.

Getting the environment variables supplied to your Cloud Foundry application with Python 3 Flask

When I was trying to build a Python 3 Flask application on Cloud Foundry, I wanted to quickly check the environment variables that Cloud Foundry will supply to my application.

As a result of that, I created a Python 3 Flask application that will probe the environment variables that it receives from Cloud Foundry.

This post lists the files that constitute that Python 3 Flask application.

How to use Flask-APScheduler in your Python 3 Flask application to run multiple tasks in parallel, from a single HTTP request

When you build an API endpoint that serves HTTP requests to work on long-running tasks, consider using a scheduler. Instead of holding up a HTTP client until a task is completed, you can return an identifier for the client to query the task status later. In the meantime, your HTTP server can offload the task to a scheduler which will complete it and update the status.

When you are building your HTTP server with Python 3 Flask, Flask-APScheduler gives you the facilities to schedule tasks to be executed in the background.

In this post, we look at how we can get Flask-APScheduler to run multiple tasks in parallel, from a single HTTP request.