Skip to main content

Utility for load static in AioHttp web framework from Webpack with help of webpack-bundle-tracker JS plugin.

Also this can be used with VueJS.

Usage:

settings.py:

    STATIC_URL = '/static/'
    STATIC_PATH = './static/'
    WEBPACK_MANIFEST_PATH = './frontend/webpack_manifest.json'

main.py:

    from aiohttp import web
    import aiohttp_jinja2
    import jinja2
    from aiohttp_webpack import WebpackManifest
    from settings import *


    @aiohttp_jinja2.template('index.html')
    async def index(request):
        context = {
            'webpack': webpack_manifest.get_links(),
        }

        return context


    if __name__ == '__main__':
        loop = asyncio.get_event_loop()

        app = web.Application()
        aiohttp_jinja2.setup(app, loader=jinja2.FileSystemLoader('./templates'))

        webpack_manifest = WebpackManifest(WEBPACK_MANIFEST_PATH, STATIC_URL, STATIC_PATH)

        app.add_routes([
            web.get('/', index),
            web.get('/static/{path:.*}', webpack_manifest.handle_static),
        ])

        web.run_app(app)

index.html:

    <html>
      <head>
        <meta charset="utf-8">
        <link rel="stylesheet" href="/static/index.css"> {# here you can use non webpack static too #}
        {{ webpack.css | safe }}
      </head>
      <body>
        <div id="app"></div> {# if you use VueJS #}
        {{ webpack.js | safe }}
      </body>
    </html>

Release files for aiohttp-webpack 0.0.7

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-webpack 0.0.7
File Size Uploaded
aiohttp-webpack-0.0.7.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiohttp-webpack 0.0.7
File Interpreter ABI Platform
aiohttp_webpack-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size:6.8 kB

Release files / aiohttp-webpack-0.0.7.tar.gz

Download URL aiohttp-webpack-0.0.7.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
833605b609c672f498c537755328eee44b7d6019e7ef45f9993c7033fa43922a
BLAKE2b-256 checksum
How to use checksums
e562c2096da2677406e313247789a66b9ad83634f214c1bf06fa8194a3b426d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

Release files / aiohttp_webpack-0.0.7-py3-none-any.whl

Download URL aiohttp_webpack-0.0.7-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2005365fc90daf91d7ee785179a11588d8e0aaab27dd3d52d7455ec0db16171
BLAKE2b-256 checksum
How to use checksums
5bb0a304606311bdf65f2de1dc054e4865aa6355e1b9eaf4d27f3a7ceda40eb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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