Skip to main content

SStatic file support for bareasgi

Project description

# 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)
```

Project details


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-0.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

bareasgi_static-0.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file bareasgi_static-0.0.1.tar.gz.

File metadata

  • Download URL: bareasgi_static-0.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for bareasgi_static-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9906cf9c1d61d1931f10596e7426f76691cee278a232172067f1945765684346
MD5 decaedb90e23d67c0d162513a3a8ba9e
BLAKE2b-256 383c72c190344d90a990b30e931a0463859fd1b2a694ff1d8982487614c4f0cd

See more details on using hashes here.

File details

Details for the file bareasgi_static-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: bareasgi_static-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for bareasgi_static-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6657ab4f63b09f2fa4934457b444329eb1acf8e94257569483ac817f97ae64e9
MD5 df75b6d6c246fb72500ff44be0aef8f3
BLAKE2b-256 394a095d7e392fdcf2fbe8a97f96e7ccf247bc1fb0de11e9e4689f3d4dd06fa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page