Skip to main content

Static file support for bareASGI

Project description


Static file support for bareASGI (read the documentation)


This package provides support for serving static files to bareasgi.


The following example serves a single file.

import uvicorn
import os.path
from bareasgi import Application
from bareasgi_static import file_response

here = os.path.abspath(os.path.dirname(__file__))

async def http_request_callback(scope, info, matches, content):
    return await file_response(scope, 200, os.path.join(here, 'file_stream.html'))

app = Application()
app.http_router.add({'GET'}, '/example1', http_request_callback), port=9010)

The next example serves files below a given directory.

import os.path
import uvicorn
from bareasgi import Application
from bareasgi_static import add_static_file_provider

here = os.path.abspath(os.path.dirname(__file__))

app = Application()
add_static_file_provider(app, os.path.join(here, simple_www), index_filename='index.html'), port=9010)

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 bareasgi-static, version 4.0.0a0
Filename, size File type Python version Upload date Hashes
Filename, size bareASGI_static-4.0.0a0-py3-none-any.whl (9.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size bareASGI-static-4.0.0a0.tar.gz (8.7 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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page