Skip to main content

aiohttp-debugmode

This package helps you easily start a aiohttp develpment server in subprocess ,everytime dependencies/statics are modified ,daemon process will automatically reload server thus helps you automation your workflow. Aiohttp-debugtoolbar included.

fury licence pyversions Publish build

  • Based on watchdog.
  • Works on Python3.7+
  • aiohttp-debugtoolbar included ,thus you can get a full report of traceback if exception raised.

(* Screenshot from aio-libs/aiohttp-debugtoolbar *)

Install

pip install aiohttp-debugmode

Usage

quick_start.py # here's a demo script from aiohttp.doc\quickstart

from aiohttp import web
routes = web.RouteTableDef()

@routes.get('/')
async def hello(request):
    return web.Response(text="Hello, world")

app = web.Application()
app.add_routes(routes)
web.run_app(app)

Simply modify severl lines like this

# Add import
from aiohttp_debugmode import Debugmode

# Let Debugmode take over control of run_app
Debugmode.run_app(app)

By default ,templates & static floder is added to observing list of watchdog. You can manually set observe file/floder using append_observe.

Debugmode.append_observe(['other/login.html' ,'assets'])

If you need some kind of process when a aiohttp server starts up:

def stup():
	... # do something

Debugmode.on_startup(stup) # accepts callable.

Examples

aiohttp-debugmode with Vue

Assume that you are usiung vue-cli and have a directory structure like this:

...
├── Project
│   ├── static
│   ├── templates
│   ├── app.py               # aiohttp app entry
│   └── frontend             # vue frontend folder
│       ├── dist             # webpack output directory
│       │   ├── css
│       │   ├── js
│       │   └── index.html
│       ├── node_modules
│       │   └── ...
│       ├── src              # vue source
│       │   └── ...
│       └── vue.config.js
│   └── ...

Assume that webpack outputs built file into /Project/frontend/dist floder while your aiohttp app collects templates & statics from /Project/templates & /Project/static folder.

Here's a sample code:

from aiohttp import web
from aiohttp_debugmode import Debugmode
import aiohttp_jinja2

# Pretended doing some tempate rander stuff.
# @aiohttp_jinja2.template('index.html')
async def hello(request):
    return web.Response(text="Randered.") 

# Debugtoolbar included thus you can get 
# a full report of traceback.
async def error(request):
    raise Exception('Testing.')

app = web.Application()
app.router.add_route('GET', '/', hello)
app.router.add_route('GET', '/err', error)
app.add_routes([web.static('/', 'static')])

def initialize():
    import shutil , os , glob
    # You may use os.path.abspath to get absolute path in some situation.
    if os.path.exists('frontend\dist\index.html'):
        shutil.move('frontend\dist\index.html' , 'templates')
        try:
            shutil.rmtree(filepath)
            os.mkdir(filepath)
            for filepath in glob.glob('frontend\dist\*'):
                shutil.move(filepath , 'static')
        except Exception as e:
            raise e

Debugmode.append_observe(['frontend\dist']) # backslashes on windows.
Debugmode.on_startup(initialize)
# Debugmode takes over run_app instead of web.run_app
Debugmode.run_app(app , host = '127.0.0.1' , port = 8080)

Thus every time you run npm run build ,debugmode will catch file modified event ,init file directory and restart aiohttp server with new generated html/js/css file.

Metadata

Release files for aiohttp-debugmode 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohttp-debugmode 0.2.1
File Size Uploaded Provenance Actions
aiohttp-debugmode-0.2.1.tar.gz 7.7 kB Without provenance Details for aiohttp-debugmode-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-debugmode 0.2.1
File Interpreter ABI Platform Actions
aiohttp_debugmode-0.2.1-py3-none-any.whl Python 3 none any Details for aiohttp_debugmode-0.2.1-py3-none-any.whl

Total release size: 18.1 kB

Release files / aiohttp-debugmode-0.2.1.tar.gz

Download URL aiohttp-debugmode-0.2.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d6193ca7e5b15c6f126ccafcb94278da1e8db39a3049f00f2cdf70032b764e22
BLAKE2b-256 checksum
How to use checksums
6dc84e0fe837341409832769335d355cd3f61cc7c714f6306791455ae3eac152
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / aiohttp_debugmode-0.2.1-py3-none-any.whl

Download URL aiohttp_debugmode-0.2.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0455e1b2bee958da6a34f1b510502240be156ad4a6149e4d6bbd2537c27f487
BLAKE2b-256 checksum
How to use checksums
264658712e7a98229ddfdc040368bb9b339d5d7e2791785e27064ef7fe9137cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Security for aiohttp-debugmode 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page