Smapy
Simple Modular APIs written in Python.
- Free software: MIT license
- Documentation: https://smapy.github.io/smapy
Overview
Smapy is a framework built on top of Falcon and gunicorn, which allows building modular, distributed and asynchronous-capable service oriented Web APIs writing as little Python code as possible.
Installation
The simplest and recommended way to install Smapy is using pip:
pip install smapy
Alternatively, clone the repository and install it from source running the make install command.
git clone git@github.com:smapy/smapy.git
cd smapy
make install
For development, you can use the make install-develop command instead in order to install all
the required dependencies for testing and code linting.
Getting Started
All you need to start a Smapy application is to execute the smapy command line utility:
$ smapy
[2018-12-29 21:53:03 +0100] [25213] [INFO] Starting gunicorn 19.9.0
[2018-12-29 21:53:03 +0100] [25213] [INFO] Listening at: http://127.0.0.1:8001 (25213)
[2018-12-29 21:53:03 +0100] [25213] [INFO] Using worker: gevent
[2018-12-29 21:53:03 +0100] [25216] [INFO] Booting worker with pid: 25216
2018-12-29 21:53:03,304 - 25216 - INFO - None - application - Initializing the API
2018-12-29 21:53:03,307 - 25216 - INFO - None - api - Adding new runnable hello.World
2018-12-29 21:53:03,307 - 25216 - INFO - None - api - Adding new runnable misc.MultiProcess
2018-12-29 21:53:03,307 - 25216 - INFO - None - api - Adding new runnable misc.Report
2018-12-29 21:53:03,308 - 25216 - INFO - None - api - Adding new runnable misc.HelloWorld
After that, you can start playing with it through HTTP requests:
$ curl localhost:8001/hello
{
"elapsed": 0.08,
"host": "hostname",
"in_ts": "2018-05-06T20:37:48.671867",
"out_ts": "2018-05-06T20:37:48.671947",
"pid": 31789,
"results": null,
"session": null,
"status": "404 Not Found"
}
$ curl localhost:8001/hello_world
{
"elapsed": 12.044,
"host": "hostname",
"in_ts": "2018-05-06T20:37:58.759039",
"out_ts": "2018-05-06T20:37:58.771083",
"pid": 31789,
"results": null,
"session": "5aef67a6ab17857c2d81a6ea",
"status": "200 OK"
}
$ curl localhost:8001/hello_world?sync=True
{
"elapsed": 26.668,
"host": "hostname",
"in_ts": "2018-05-06T20:38:03.903315",
"out_ts": "2018-05-06T20:38:03.929983",
"pid": 31789,
"results": {
"hello": "world!",
"sync": "True"
},
"session": "5aef67abab17857c2d81a6ec",
"status": "200 OK"
}
$ curl localhost:8001/report?session=5aef67a6ab17857c2d81a6ea
{
"elapsed": 19.758,
"host": "hostname",
"in_ts": "2018-05-06T20:39:49.670267",
"out_ts": "2018-05-06T20:39:49.690025",
"pid": 31789,
"results": {
"actions": {
"OK": 1
},
"last_activity": "2018-05-06T20:37:58.812000",
"session": {
"_id": "5aef67a6ab17857c2d81a6ea",
"alive": false,
"body": {},
"elapsed": "0:00:00.058000",
"env": {
"HTTP_ACCEPT": "*/*",
"HTTP_HOST": "localhost:8001",
"HTTP_USER_AGENT": "curl/7.47.0",
"PATH_INFO": "/hello_world",
"QUERY_STRING": "",
"RAW_URI": "/hello_world",
"REMOTE_ADDR": "127.0.0.1",
"REMOTE_PORT": "50636",
"REQUEST_METHOD": "GET",
"SCRIPT_NAME": "",
"SERVER_NAME": "127.0.0.1",
"SERVER_PORT": "8001",
"SERVER_PROTOCOL": "HTTP/1.1",
"SERVER_SOFTWARE": "gunicorn/19.8.1"
},
"host": "hostname",
"in_ts": "2018-05-06T20:37:58.759000",
"out_ts": "2018-05-06T20:37:58.817000",
"params": {},
"pid": 31789,
"resource": "misc.HelloWorld",
"response": {
"hello": "world!"
},
"status": "OK",
"sync": false
},
"session_data": {
"links": 0,
"occurrences": 0,
"post": 0
}
},
"session": "5aef6815ab17857c2d81a6ef",
"status": "200 OK"
}
History
0.0.3
New release scripts.
0.0.2
- Add
smapyCLI - Add default actions ands resources
- Import actions dynamically
- Update project structure
0.0.1
- First release on PyPI.
Metadata
Release files for smapy 0.0.3
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 |
|---|---|---|---|---|
| smapy-0.0.3.tar.gz | 33.3 kB | Without provenance | Details for smapy-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smapy-0.0.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for smapy-0.0.3-py2.py3-none-any.whl |
Total release size: 51.7 kB
Release files / smapy-0.0.3.tar.gz
| Download URL | smapy-0.0.3.tar.gz |
|---|---|
| Size | 33.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ffdb348381549ca99f60dcbae344233406771515d64a1800dcad2f9a1630921
|
|
BLAKE2b-256 checksum How to use checksums |
79e0b47c32a0b05447b0cd50995487dcc4f918bee38eb30d7fbf8f78e42d6593
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
|
Release files / smapy-0.0.3-py2.py3-none-any.whl
| Download URL | smapy-0.0.3-py2.py3-none-any.whl |
|---|---|
| Size | 18.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
51e336cc7a77d2ce9da415c0bc9bae2c46ced60d86472b7519800798c7532605
|
|
BLAKE2b-256 checksum How to use checksums |
a1adf2254a94ae7454d55dc8d466f41a0e10afc29aa29ff07d09100e1b51bfef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.6.8
|
Security for smapy 0.0.3
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.