Skip to main content

SStatic 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


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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bareasgi_static-1.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bareasgi_static-1.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for bareasgi_static-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7a2f26dcd2df8118643bbf28b9712c8a1f1fdd3e2bcad086eb94f13557056a1f
MD5 403bc263572d1a7ee9fd6abe47221f43
BLAKE2b-256 47604c970582aefc2ce7401e62b6d1b8090df1192fcc02ff8f44ed7fc38ee65d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bareasgi_static-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for bareasgi_static-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63c2abd9bba370f9583773ba5c42a8b7cdfbd0c95777924e1b5f8732b3eded1a
MD5 41ea0122d52356847cd4c6de72e9898c
BLAKE2b-256 c0d4846c2db7a928e6048e9edae22aedae3d332075ac61a6736fc70096ce0f03

See more details on using hashes here.

Supported by

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