Metadata-Version: 2.1
Name: fooster-web
Version: 0.4.0rc1
Summary: a small, process-pooled web server utilizing the built-in Python socketserver
Home-page: https://github.com/lilyinstarlight/python-fooster-web
Author: Lily Foster
Author-email: lily@lily.flowers
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: Freely Distributable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.6
Description-Content-Type: text/markdown

fooster-web
===========

fooster-web is a small, process-pooled web server utilizing the built-in Python socketserver. It is designed from the ground up to be well structured, to conform to the HTTP/1.1 standard, and to allow for easy creation of a RESTful interface.

[![Build Status](https://img.shields.io/github/workflow/status/lilyinstarlight/python-fooster-web/Tox)](https://github.com/lilyinstarlight/python-fooster-web/actions?query=workflow%3ATox) [![Coverage Status](https://img.shields.io/codecov/c/github/lilyinstarlight/python-fooster-web)](https://codecov.io/github/lilyinstarlight/python-fooster-web)


Usage
-----

Below is a basic example that stores data via a PUT method and retrieves data via a GET method on any resource. If a resource has not been set, it returns a 404 error.

```python
import fooster.db

import fooster.web


data = fooster.db.Database('data.db', ['path', 'body'])


class Handler(fooster.web.HTTPHandler):
    def do_get(self):
        try:
            return 200, data[self.groups['path']].body
        except KeyError:
            raise fooster.web.HTTPError(404)

    def do_put(self):
        data[self.groups['path']] = data.Entry(self.request.body.decode())

        return 200, 'Accepted\n'

    def do_delete(self):
        try:
            del data[self.groups['path']]
        except KeyError:
            raise fooster.web.HTTPError(404)

        return 200, 'Deleted\n'


routes = {r'/(?P<path>.*)': Handler}


if __name__ == '__main__':
    import signal

    httpd = fooster.web.HTTPServer(('localhost', 8000), routes)

    httpd.start()

    signal.signal(signal.SIGINT, lambda signum, frame: httpd.close())

    httpd.join()
```

Examples and more information are available at the [wiki](https://github.com/lilyinstarlight/python-fooster-web/wiki).


