cleanapi
Pretty tornado wrapper for making lightweight REST API services
Installation:
pip install cleanapi
Example:
Project folders structure:
.
├── handlers
│ └── example_handler.py
├── server_example.py
├── ssl
│ ├── ca.csr
│ └── ca.key
└── static_html
└── index.html
server_example.py
from cleanapi import server
if __name__ == '__main__':
try:
# protocol = 'https'
protocol = 'http'
if protocol == 'https':
server.start(protocol, 8080, '/', './handlers', './static_html',
path_to_ssl='./ssl', ssl_certfile_name='ca.csr', ssl_keyfile_name='ca.key')
elif protocol == 'http':
server.start(protocol, 8080, '/', './handlers', './static_html')
else:
print(f'Protocol {protocol} is not supported')
except KeyboardInterrupt:
print('Server was stopped by user')
exit()
example_handler.py
Put it to the 'handlers' folder
from cleanapi import BaseHandler
url_tail = '/example.json'
# noinspection PyAbstractClass
class Handler(BaseHandler):
"""
Test API request handler
"""
async def get(self):
self.set_status(200)
self.write({'status': 'working'})
index.html
Put it to the 'static_html' folder
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cleanapy demo</title>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
</head>
<body>
<h1>Cleanapy demo page</h1>
<p>Everything OK</p>
</body>
</html>
You also may put 'favicon.ico' file to the 'static_html' folder
Then you can test server responses on http://localhost:8080 and http://localhost:8080/example.json
Metadata
Release files for cleanapi 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| cleanapi-0.1.1.tar.gz | 15.7 kB | Without provenance | Details for cleanapi-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cleanapi-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for cleanapi-0.1.1-py3-none-any.whl |
Total release size: 31.9 kB
Release files / cleanapi-0.1.1.tar.gz
| Download URL | cleanapi-0.1.1.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22223e41703fb04e8c46627b1ba34ac8708a758a3e316e9d484ec7a8b39d1bec
|
|
BLAKE2b-256 checksum How to use checksums |
429adf4b87c0436d67473a9046ac9869797ffcdd8ca08cd41aa0b6bd92120430
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Release files / cleanapi-0.1.1-py3-none-any.whl
| Download URL | cleanapi-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9bd5ff02209dd4322ae0eb19f0ed3a568553229b09e06b6b7922647b33f9c974
|
|
BLAKE2b-256 checksum How to use checksums |
7e44aeaca3568b0f8b0b50694772d86145a108e42e88869980a946cf27c69468
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Security for cleanapi 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.