Metadata-Version: 1.2
Name: ASGIMiddlewareStaticFile
Version: 0.2.0
Summary: ASGI Middleware for serving Static File.
Home-page: https://github.com/rexzhang/asgi-middleware-static-file
Author: Rex Zhang
Author-email: rex.zhang@gmail.com
License: MIT
Description: ========================
        ASGIMiddlewareStaticFile
        ========================
        
        
        .. image:: https://img.shields.io/pypi/v/ASGIMiddlewareStaticFile.svg
            :target: https://pypi.org/project/ASGIMiddlewareStaticFile/
        .. image:: https://img.shields.io/pypi/pyversions/ASGIMiddlewareStaticFile.svg
            :target: https://pypi.org/project/ASGIMiddlewareStaticFile/
        .. image:: https://img.shields.io/pypi/dm/ASGIMiddlewareStaticFile.svg
            :target: https://pypi.org/project/ASGIMiddlewareStaticFile/
        
        ASGI Middleware for serving Static File.
        
        
        Install
        =======
        
        .. code-block:: console
        
            pip3 install -U ASGIMiddlewareStaticFile
        
        
        Usage
        =====
        
        Pure ASGI
        ---------
        
        .. code-block:: python
        
            import os
            from wsgiref.simple_server import make_server
            from asgi_middleware_static_file import ASGIMiddlewareStaticFile
        
            BASE_DIR = os.path.dirname(__name__)
            STATIC_DIRS = [os.path.join(BASE_DIR, 'static')]
        
        
            def app(env, start_response):
                start_response('200 OK', [('Conte-type', 'text/plain; charset=utf-8')])
                return [b'Hello World']
        
            app = ASGIMiddlewareStaticFile(app, static_url='static', static_paths=STATIC_DIRS)
        
            if __name__ == '__main__':
                httpd = make_server('', 8000, app)
                httpd.serve_forever()
        
        Django
        ------
        
        Update ``asgi.py``
        
        .. code-block:: python
        
        
            import os
        
            from django.conf import settings
            from django.core.asgi import get_asgi_application
            from asgi_middleware_static_file import ASGIMiddlewareStaticFile
        
            os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dj_project.settings')
            application = get_asgi_application()
            application = ASGIMiddlewareStaticFile(
                application, static_url=settings.STATIC_URL, static_paths=[settings.STATIC_ROOT]
            )
        
        
        Do't forget execute ``python manage.py collectstatic``
        
        Run server
        
        .. code-block:: console
        
            daphne dj_project.asgi:application -b 0.0.0.0
            2020-04-14 17:20:57,530 INFO     Starting server at tcp:port=8000:interface=0.0.0.0
            2020-04-14 17:20:57,531 INFO     HTTP/2 support not enabled (install the http2 and tls Twisted extras)
            2020-04-14 17:20:57,531 INFO     Configuring endpoint tcp:port=8000:interface=0.0.0.0
            2020-04-14 17:20:57,532 INFO     Listening on TCP address 0.0.0.0:8000
            127.0.0.1:62601 - - [14/Apr/2020:17:21:08] "GET /static/css/emo.css" 200 1692
        
        
        
        Alternative
        ===========
        
        - ASGI Middleware
            - django.contrib.staticfiles.handlers.ASGIStaticFilesHandler
        - WSGI Middleware
            - https://github.com/kobinpy/wsgi-static-middleware
            - https://pypi.org/project/whitenoise/
        
Keywords: asgi middleware staticfile
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.5
