cirrina is an opinionated asynchronous web framework based on aiohttp

Overview

cirrina

cirrina is an opinionated asynchronous web framework based on aiohttp.

Features:

  • HTTP Server
  • Websocket Server
  • JSON RPC Server
  • Shared sessions between used servers
from cirrina import Server

app = Server()

# Define HTTP route for static files
app.static("/static", Server.DEFAULT_STATIC_PATH)

# enable websocket communication
app.enable_websockets()

# enable JSON RPC communication
app.enable_rpc('/jrpc')

if __name__ == '__main__':
    app.run('0.0.0.0')

Installation

Use pip to install cirrina:

pip install cirrina
Comments
  • Allow to specify keywords to aiohttp Application

    Allow to specify keywords to aiohttp Application

    This allows to specify aiohttp.Application kws: see https://docs.aiohttp.org/en/stable/web_reference.html#aiohttp.web.Application

    E.g.: for middlewares

            cirrina.Server(app_kws={
                'middlewares': [error_middleware]
            })
    
    opened by lbolla 2
  • Move static files to example

    Move static files to example

    Does the javascript websocket client implementation really belong to the package content? It's just another implementation of a client which is able to talk to a cirrina server. The examples/documentation might be a better place.

    opened by timofurrer 1
  • Use decorators to register locations instead of class inheritance

    Use decorators to register locations instead of class inheritance

    Note: work in progress ... do NOT merge

    • [x] Register HTTP routes via decorators
    • [x] Register websocket callbacks via decorators
    • [x] Enable websockets and JRPC
    • [ ] Pass context object

    (1) Register HTTP routes via decorators

    @app.get('/')
    async def index():
        pass
    

    (2) Register websocket callbacks via decorators

    @app.websocket_connect
    async def on_websocket_connect():
        pass
    

    (3) Enable websockets and JRPC

    app.enable_websockets()
    app.enable_rpc('/jrpc')
    

    (4) Easy setup of cirrina app

    app = cirrina.Server()
    
    @app.get('/')
    async def index():
        pass
    
    if __name__ == '__main__':
        app.run()
    
    opened by timofurrer 1
  • asyncio.Task.all_tasks disappeared in Python 3.9

    asyncio.Task.all_tasks disappeared in Python 3.9

    When shutting down cirrina while using Python 3.9, I get this error:

    ^CTraceback (most recent call last):
    ...
      File "/usr/lib/python3/dist-packages/cirrina/server.py", line 183, in run
        for task in asyncio.Task.all_tasks():
    AttributeError: type object '_asyncio.Task' has no attribute 'all_tasks'
    

    The problem is that asyncio.Task.all_tasks was deprecated in py3.7 and removed in py3.9: https://docs.python.org/3.8/library/asyncio-task.html#asyncio.Task.all_tasks

    opened by lbolla 0
  • Don't swallow exceptions in session wrapper

    Don't swallow exceptions in session wrapper

    This patch permits to use aiohttp idiomatic use of exceptions for control flow (e.g. raise aiohttp.web.HTTPFound('/redirect')).

    Also, if creating and tearing down the session context fails, it's best to just fail with a 500 error rather then continuing with the request: so, don't try/catch errors there either.

    Python's exception chaining will still preserve the original error (if any), in case an error is raised in the cleanup (finally) branch.

    Fix #27

    opened by lbolla 0
  • Session handling swallows exceptions

    Session handling swallows exceptions

    The session wrapper swallows any exception, therefore preventing aiohttp idiomatic use of HTTPExceptions for control flow.

    For example, this handler wouldn't work (see https://docs.aiohttp.org/en/stable/web_quickstart.html#exceptions):

    async def handler(request):
        raise aiohttp.web.HTTPFound('/redirect')
    

    because the exception would be caught in the above "session wrapper" except clauses and never re-raised.

    opened by lbolla 0
  • Fix deprecation warnings

    Fix deprecation warnings

    When running cirrina, I got these deprecation warnings:

    tests/test_remotescreen.py::RemoteScreenTest::test_query
      /home/users/bollal/.virtualenvs/rlx-web/lib/python3.7/site-packages/aiohttp/web_urldispatcher.py:188: DeprecationWarning: Bare functions are deprecated, use async ones
        "Bare functions are deprecated, " "use async ones", DeprecationWarning
    
    tests/test_app.py::AppTest::test_logout
      /home/users/bollal/src/github.com/neolynx/cirrina/cirrina/server.py:305: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
        self.logger.warn('No valid session in request for logout')
    

    This PR fixes both.

    opened by lbolla 0
  • Enable python 3.8

    Enable python 3.8

    Hi @neolynx,

    To enable cirrina in https://github.com/the-benchmarker/web-frameworks/issues/1638, I need to make it runnable on python 3.8.

    This PR :

    • [x] Add classifiers to setup.py so it could be installable in python >= 3.5
    • [x] Add python >= 3.5 on CI
    • [x] Fix CI to push on pypi

    Regards,

    opened by waghanza 0
  • UnboundLocalError when uploading files

    UnboundLocalError when uploading files

    When uploading files, it's possible that "recived_filename" is not yet defined when it's used. See: https://github.com/neolynx/cirrina/blob/8c69c0ea4e4a03ce4f9f91ecda48d16bd832ab7f/cirrina/server.py#L458

    E.g. error log:

    local variable 'received_filename' referenced before assignment
                                                   Traceback (most recent call last):
                                                     File "/opt/roche/home/cirrina/cirrina/server.py", line 356, in _wrap
                                                       ret = (await func(request))
                                                     File "/opt/roche/home/cirrina/cirrina/server.py", line 458, in upload_handler
                                                       filename = received_filename.replace("\"", "")
                                                   UnboundLocalError: local variable 'received_filename' referenced before assignment
    
    opened by lbolla 0
  • #21 and #10

    #21 and #10

    General cleanup and update. In the last 7 months aiohttp has grown quite a lot.

    - Fixed PEP8
    - Removed lots of duplicate code
    - Updated to aiohttp 2.2
    - Removed backwards compatibility pre-python3.5
      to use aiohttp's async with functionality and async def, much clearer syntax
    - Using new aiohttp startup methods and signals
    - Added TODO entries regarding login methods
    - Removed old-and-unused debian files
    - Fixed client style
    - Moved documentation outside, deprecated websocket client library
    

    I'm planning on adding individual websocket handling (by session or by a self-assigned id in authless use cases) and an aiohttp websocket client example soon. This PR lacks a lot of testing, does major changes and breaks things.

    I've not added tests nor sphinx doc because I first wanted to see your opinion on the current PR, @neolynx

    opened by XayOn 1
Owner
André Roth
André Roth
Dazzler is a Python async UI/Web framework built with aiohttp and react.

Dazzler is a Python async UI/Web framework built with aiohttp and react. Create dazzling fast pages with a layout of Python components and bindings to update from the backend.

Philippe Duval 17 Oct 18, 2022
Fast, asynchronous and elegant Python web framework.

Warning: This project is being completely re-written. If you're curious about the progress, reach me on Slack. Vibora is a fast, asynchronous and eleg

vibora.io 5.7k Jan 8, 2023
Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.

Tornado Web Server Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. By using non-blocking ne

null 20.9k Jan 1, 2023
An easy-to-use high-performance asynchronous web framework.

An easy-to-use high-performance asynchronous web framework.

Aber 264 Dec 31, 2022
An easy-to-use high-performance asynchronous web framework.

中文 | English 一个易用的高性能异步 web 框架。 Index.py 文档 Index.py 实现了 ASGI3 接口,并使用 Radix Tree 进行路由查找。是最快的 Python web 框架之一。一切特性都服务于快速开发高性能的 Web 服务。 大量正确的类型注释 灵活且高效的

Index.py 264 Dec 31, 2022
Asynchronous HTTP client/server framework for asyncio and Python

Async http client/server framework Key Features Supports both client and server side of HTTP protocol. Supports both client and server Web-Sockets out

aio-libs 13.2k Jan 5, 2023
Asita is a web application framework for python based on express-js framework.

Asita is a web application framework for python. It is designed to be easy to use and be more easy for javascript users to use python frameworks because it is based on express-js framework.

Mattéo 4 Nov 16, 2021
web.py is a web framework for python that is as simple as it is powerful.

web.py is a web framework for Python that is as simple as it is powerful. Visit http://webpy.org/ for more information. The latest stable release 0.62

null 5.8k Dec 30, 2022
A very simple asynchronous wrapper that allows you to get access to the Oracle database in asyncio programs.

cx_Oracle_async A very simple asynchronous wrapper that allows you to get access to the Oracle database in asyncio programs. Easy to use , buy may not

null 36 Dec 21, 2022
Free and open source full-stack enterprise framework for agile development of secure database-driven web-based applications, written and programmable in Python.

Readme web2py is a free open source full-stack framework for rapid development of fast, scalable, secure and portable database-driven web-based applic

null 2k Dec 31, 2022
FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins.

FPS, fast pluggable server, is a framework designed to compose and run a web-server based on plugins. It is based on top of fastAPI, uvicorn, typer, and pluggy.

Adrien Delsalle 1 Nov 16, 2021
APIFlask is a lightweight Python web API framework based on Flask and marshmallow-code projects

APIFlask APIFlask is a lightweight Python web API framework based on Flask and marshmallow-code projects. It's easy to use, highly customizable, ORM/O

Grey Li 705 Jan 4, 2023
Web framework based on type hint。

Hint API 中文 | English 基于 Type hint 的 Web 框架 hintapi 文档 hintapi 实现了 WSGI 接口,并使用 Radix Tree 进行路由查找。是最快的 Python web 框架之一。一切特性都服务于快速开发高性能的 Web 服务。 大量正确的类型

Aber 19 Dec 2, 2022
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

Sanic Community Organization 16.7k Jan 8, 2023
The Web framework for perfectionists with deadlines.

Django Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Thanks for checking it out. All docu

Django 67.9k Dec 29, 2022
The Python micro framework for building web applications.

Flask Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to co

The Pallets Projects 61.5k Jan 6, 2023
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

Sanic Community Organization 16.7k Dec 28, 2022
bottle.py is a fast and simple micro-framework for python web-applications.

Bottle: Python Web Framework Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module a

Bottle Micro Web Framework 7.8k Dec 31, 2022
Pyramid - A Python web framework

Pyramid Pyramid is a small, fast, down-to-earth, open source Python web framework. It makes real-world web application development and deployment more

Pylons Project 3.7k Dec 30, 2022