Skip to main content

A quick and lightweight server framework.

Project description

======================================== Asynchronous server component library

.. image:: :target: :alt: Travis status for master branch

.. image:: :target: :alt: Codecov

.. image:: :target: :alt: License

.. image:: :target: :alt: PyPI


  • Manage common modules (MySQLModule, HttpServerModule) with Application class.
  • Web routing configures the handler through the decorator.
  • SQL normalization, avoiding heavy ORM, while also making readability.

Getting started


An example using a server:

.. code-block:: python


from aiohttp import web
from tomato.transport.http import Routes

routes = Routes()

async def xxx(request):
    name = request.match_info.get('name', "Anonymous")
    text = "Hello, " + name
    return web.Response(text=text)

.. code-block:: python


from hello_handler import routes
from tomato.util import Application
from tomato.transport import HttpServerModule

app = Application()
app['http_server'] = HttpServerModule(host='localhost', port=1024, routes_list=[routes, ])
# app.stop()


.. code-block:: python

import asyncio
from tomato.util import Application
from import MySQLModule
from import SqlClauseAssemble
from import SqlParamCollections

app = Application()
# setting parameter is a dictionary type
app['mysql'] = MySQLModule(setting=mysql_setting)
sql_assemble = SqlClauseAssemble()
sql_assemble.wanted_words = ['platform_id', 'open_id']
sql_assemble.table_name = '`app_account_users`'
where_params = SqlParamCollections()
where_params.add_normal_param(('open_id', '=', 18888888888, True))
sql_assemble.where_params = where_params
(sql, params) = sql_assemble.get_query_clause()
print((sql, params))
loop = asyncio.get_event_loop()
result_list = loop.run_until_complete(app['mysql'].get_all(sql,params))


.. code-block:: python

from tomato.util import Application
from import RedisModule

app = Application()
app['redis'] = RedisModule(setting=redis_setting)
redis = RedisController()
loop = asyncio.get_event_loop()
loop.run_until_complete(redis.set('my-key', 'my-value'))
assert loop.run_until_complete(redis.get('my-key')) == 'my-value'


  • server <>_

  • mysql <>_

Dependent library

  • aiohttp <>_

Other contributors

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tomatolib, version 0.4.5
Filename, size File type Python version Upload date Hashes
Filename, size tomatolib-0.4.5.tar.gz (17.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page