Static file support for bareASGI
Project description
bareasgi-static
Static file support for bareASGI (read the documentation)
Overview
This package provides support for serving static files to bareasgi.
Usage
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)
uvicorn.run(app, 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')
uvicorn.run(app, port=9010)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bareASGI-static-3.0.2.tar.gz
(8.6 kB
view hashes)
Built Distribution
Close
Hashes for bareASGI_static-3.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 901c4626cbd9c9dd462e641b6c08b97080a03e8b497f42208f4186c61839341c |
|
MD5 | c672e57898465927acc12f67a74ad6fc |
|
BLAKE2b-256 | 1de52e65c61e76dc5a63cc380ad193aefa4911ad0ae6f4d057b2da64219e3c03 |