Skip to content
Muslu Yüksektepe

cemirfw

A lightweight, all-in-one web framework experiment for Python and PyPy.

cemirfw is a framework experiment aimed at running on Python and PyPy, trying to gather the basic pieces needed to write a web service into a single package. It was published on PyPI in June 2024 as a single release, described as an all-in-one framework for Python and PyPy. PyPy is an alternative Python interpreter that in many cases runs Python code faster than the standard one.

Purpose

When writing small APIs, I had to put together separate libraries for routing, parameter checking, caching, authentication and database access every time. With cemirfw I aimed to bring these pieces under one structure and to be able to define an endpoint with a function of a few lines. Installing and managing the framework as a system service was also part of the goal from the start.

How it works

According to the examples in the README, endpoints are defined with decorators named after HTTP methods, such as get and put. Along with the address, the decorator is told whether authentication is required and how Redis caching should work. The cache settings say how many seconds an entry is kept and which details the cache key is built from, for example the client's IP address and browser information. The check_params decorator checks that required parameters are present in the request before the function runs. Endpoint functions are written as async.

Two ways of working with the database are shown. The first is running a plain SQL query with the db_query function. The second is a chainable query builder through the Tablo class. This class can insert, update, delete and select records. When selecting, conditions such as equality, inequality, starts with, ends with and does not contain, as well as ordering, are added as a chain.

Installation is done with a shell script. After that, the cemirfw start, stop, restart, status and disable commands start and stop the service and show its state.

Key features

  • Endpoints are defined with decorators in a short, readable way.
  • Redis caching, and how the cache key is built, can be set separately for each endpoint.
  • Required parameter checks are done with a decorator.
  • A chainable query builder is available for simple database operations.

Technical stack

According to the package metadata on PyPI, the framework is built on Tornado, Python's asynchronous web server and networking library. The package metadata lists Python versions 3.6 to 3.9, and the package is distributed under the MIT license.

Status

cemirfw remained an experiment and has not been updated since the first release in 2024. The package published on PyPI contains only the README and setup information; the framework's source code is not included. Installing the package alone is therefore not enough to use the framework, and the description above is based on the examples in the README.

Use cases

  • As an idea, it was designed to get internal services and small APIs with only a few endpoints up and running quickly.
  • It targeted services with cached read endpoints and simple table operations.
  • It was meant for lightweight web applications that run as a system service on a server and are managed from the command line.
Category
Python libraries
Year
2024

Technologies

  • Python
  • PyPy
  • PyPI
  • Web Framework

Links

  • PyPI https://pypi.org/project/cemirfw/

Back to all projects