Parzibyte's blog

Free knowledge blog: linux, programming, open source, databases, android, frameworks, web and computing in general

Python Thermal Printing: A Comprehensive Guide for Printing on Thermal Printers

In this tutorial, we’ll explore how to effortlessly print receipts, invoices, and tickets on a thermal printer using Python. I’ll introduce you to a powerful plugin that I’ve developed, enabling seamless integration for Python-based applications.

With this plugin, you’ll gain the ability to effortlessly print tickets from Python, regardless of your preferred framework—whether it’s the terminal, Flask, Tkinter, Django, or any other Python-supported platform.

It provides extensive functionality, allowing you to print images, barcodes, text with accents, change fonts, rotate text, and much more, sending the ESC POS commands native to thermal printers.

Join me as we dive into the world of thermal printing using Python, empowering you to generate professional-quality prints effortlessly.

(more…)

Creating an API REST with Python, Flask and SQLite3

In this Python programming tutorial you will learn how to create a REST API using Flask, SQLite 3 (for data), and JSON for data communication.

In the end you will have an API that you can consume from any client that could be an Android application, a browser with JavaScript or even another server language.

I will show you how to create an API that communicates using JSON and saves the data in SQLite 3. The API will be created with Flask, and we will use the Python programming language to handle all the data.

(more…)

Enable CORS in Flask app

In this post I will show you how to enable CORS (Cross Origin Resource sharing) so that you can make HTTP requests from a different domain than the one you use for your Flask application written in Python.

We will just add a kind of middleware to modify all the responses and add the headers that allow CORS in Flask.

(more…)

How to install and configure Python 3 and pip on Windows 10

Introduction

In this post we will see how to install and configure the Python interpreter in its version 3 on Windows 10 (works even for 7, 8 and 8.1).

At the end we will be able to execute scripts and also to install third-party libraries using pip; which will make things easier for us.

(more…)

Switch in Python

There is no switch statement in Python, but there are equivalents depending on what you want to achieve. The best-known use of switch is to evaluate a value and avoid nesting multiple if statements.

Today I will explain it: how to make an equivalent switch in Python.

(more…)

Python: check if item or value exists in list or array

Introduction

Sometimes we need to know if an element or value is within a list or array in Python.

There may be a need to simply know if it exists, but it is also possible that we need to obtain the position of an element, that is, its index.

Today we will see how to do it in Python, to check if an element exists in array, as well as to obtain the index of a certain value.

(more…)