producti_gestio official documentation


The Main module. A simple REST-API server creator.


producti_gestio Version: 0.7.2

  • Fix installation
  • Add dependencies in
  • Automatic reading of requirements.txt in
  • Remove bin/producti-gestio, now will create the script from producti_gestio/
Main Contributors:

Welcome to producti gestio! image0 image1 image2 image3 image4 image5

producti gestio (/producti gestio/, from Latin: Product management) is a simple API like web server written in Python. It could be used for your projects and it is useful for debugging. You can start a web server in few seconds and enjoy your development session.

Using producti-gestio, you are allowed to have a coffee break, because the entire server is managed by it!



From PyPi

Just use pip:

pip install producti_gestio

Or if you want to upgrade the package:

pip install --upgrade producti_gestio

From Github

Using Pip

Try using that piece of code:

pip install git+

Or if you want to upgrade the package

pip install --upgrade git+

Downloading files

In primis (from Latin, “firstable”), clone the repository:

git clone

Then, change directory:

cd producti-gestio

And finally, install the package:

sudo python3 install


Import the library

Just use import statement:

import producti_gestio

Create an handler function

You’re going to use a decorator that will create a Wrapper. Here an example:

from producti_gestio import Server

my_server = Server(allow_get=True) # Create the server instance

def my_function(**kwargs):
    return {
        'response_code': 200, # The response code (see
        'response': { # A dictionary that will be encoded in JSON
            'ok': True,
            'message': 'Hello world!'

Then, if you call my_server.start() you’ll start the HTTPServer (using Threads):

And, if you’ll surf that will be the output:

{'ok': True, 'message': 'Hello world!'}

Get parameters, headers, etc…

Just look at the kwargs parameter. It contains a dictionary of all the informations you need.

  • Parameters -> kwargs['parameters']
  • Headers -> kwargs['header']
  • Request type -> kwargs['request-type']
  • Path requested -> kwargs['path']
  • Handler object -> kwargs['object']


You can pass your own configuration to the server-creator function Here all the keyword arguments you can pass:

  • allow_get (default is False)
  • allow_post (default is True)
  • function (default is None, but it is needed, it’s the handler_function),
  • debug (default is False, if you want to print the Traceback under error_message in the JSON response when an Exception is caught)
  • ip (default is ‘’)
  • port (default is 8000)

Run the server using decorators

Just call the handler function:

import producti_gestio

def server_create(*args, **kwargs):
   It create the server and
   launch it
   def handler_function(*args, **kwargs):
       return ({
           'response_code': 200,
           'response': {
               'ok': True,
               'is_meme': True

   return handler_function

if __name__ == '__main__':


You’ll find lots of not understandable directory and files, so here a list and definitions of them:

  • producti_gestio - Main directory
    • producti_gestio/ - Init file, it included all classes
    • producti_gestio/ - It parses and processes all given parameters from the command line
    • producti_gestio/core - Directory for all important classes such as request_handler
      • producti_gestio/core/ - It includes all core classes
      • producti_gestio/core/ - It defines a check function that could be used a decorator for filters
      • producti_gestio/core/ - The Handler of the requests, it passes parameters to the defined Handler function and then it send the JSON response
    • producti_gestio/decorator - Directory for all help-decorator classes
      • producti_gestio/decorator/ - It includes all decorator classes
      • producti_gestio/decorator/ - The Decorator class, it is used to launch the Server class and define the Handler function
    • producti_gestio/exceptions - Directory for all the exception
      • producti_gestio/exceptions/ - It includes all the exceptions
      • producti_gestio/exceptions/ - It defines all the exceptions
    • producti_gestio/filters - Directory for all the filters
      • producti_gestio/filters/ - It includes and
      • producti_gestio/filters/ - It defines the Filter class
      • producti_gestio/filters/ - It defines all the Filters
    • producti_gestio/handlers - Directory for the handlers
      • producti_gestio/handlers/ - It includes
      • producti_gestio/handlers/ - It defines the Handler class
    • producti_gestio/project - Directory of some project generator tools
      • producti_gestio/project/ - It includes the project generator
      • producti_gestio/project/ - Tools for code auto-generating
    • producti_gestio/server - The Server directory
      • producti_gestio/server/ - It includes all server classes
      • producti_gestio/server/ - The main class, it creates the server
    • producti_gestio/utils - Directory of some useful tools
      • producti_gestio/utils/ It includes the arguments parser
      • producti_gestio/utils/ - It parses and processes the given arguments from the command line

How to contribute

In primis (“firstable”), you must read the code of conducts and the contributing document, then ask @hearot to enter the organization (pyTeens).

Copyright (c) 2018 pyTeens. All rights reserved.