# bareasgi-static
Static file support for bareasgi
## Overview
This package provides support for serving static files to bareasgi.
## Usage
The following example serves a single file.
```python
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, 'example1.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.
```python
import os.path
import uvicorn
from bareasgi import Application
from bareasgi_static import StaticFiles
here = os.path.abspath(os.path.dirname(__file__))
static_files = StaticFiles(os.path.join(here, 'www'), index_filename='index.html')
app = Application()
app.http_router.add({'GET'}, '/{rest:path}', static_files)
uvicorn.run(app, port=9010)
```
Static file support for bareasgi
## Overview
This package provides support for serving static files to bareasgi.
## Usage
The following example serves a single file.
```python
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, 'example1.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.
```python
import os.path
import uvicorn
from bareasgi import Application
from bareasgi_static import StaticFiles
here = os.path.abspath(os.path.dirname(__file__))
static_files = StaticFiles(os.path.join(here, 'www'), index_filename='index.html')
app = Application()
app.http_router.add({'GET'}, '/{rest:path}', static_files)
uvicorn.run(app, port=9010)
```
Release files for bareASGI-static 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bareasgi_static-0.0.1.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bareasgi_static-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:12.4 kB
Release files / bareasgi_static-0.0.1.tar.gz
| Download URL | bareasgi_static-0.0.1.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9906cf9c1d61d1931f10596e7426f76691cee278a232172067f1945765684346
|
|
BLAKE2b-256 checksum How to use checksums |
383c72c190344d90a990b30e931a0463859fd1b2a694ff1d8982487614c4f0cd
|
| 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 / bareasgi_static-0.0.1-py3-none-any.whl
| Download URL | bareasgi_static-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6657ab4f63b09f2fa4934457b444329eb1acf8e94257569483ac817f97ae64e9
|
|
BLAKE2b-256 checksum How to use checksums |
394a095d7e392fdcf2fbe8a97f96e7ccf247bc1fb0de11e9e4689f3d4dd06fa6
|
| 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
|