morphapiwrapper
Wrapper functions for creating APIs in Morphisdom
The morphapiwrapper package contains the wrapper functions to build a API for morphisdom
Get started
You can install the package by running the following command
pip install morphapiwrapper
Then load the package in Python by running the following command
from morphapiwrapper import app, addapproute
Write your custom function
You can write your custom function with this package and serve it as an API in morphisdom
Your custom function should always take two arguments. Namely requestdata and filereaderwriter.
requestdata is the variable which would get the data passed during the API call for the client.
For multiargument API in morphisdom requestdata holds a list whose elements corresponds to individual arguments of the API function in sequence.
However requestdata can also hold string, number, boolean (for single argument API) and dictionary.
filereaderwriter is an handle for downloading GCS or remote HTTP content into localdirectory.
if requestdata contains and GCS file URI or HTTP url then the funtion filereaderwriter.download_input_data(requestdata) downloads all those files and returns the name of the local files in the same order. The number of elements in requestdata and downloadeddata remains same.
The following function demonstrates a simple function to be served as a Morphisdom API. The requestdata is downloaded and returned as output.
In order to log billing API calls the billunit needs to be set greater than 0.
def testfunction(requestdata,filereaderwriter):
downloadeddata = filereaderwriter.download_input_data(requestdata)
print(downloadeddata)
billunit = 2
return downloadeddata,billunit
Wrap your function
Once your function is created wrap your function in an flask app with the following code snippet
app = addapproute(app, testfunction)
The returned app is a flask app which has a route /testfunction added in it. On calling this route testfunction is executed
Metadata
Release files for morphapiwrapper 1.0
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 |
|---|---|---|---|---|
| morphapiwrapper-1.0.tar.gz | 5.2 kB | Without provenance | Details for morphapiwrapper-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| morphapiwrapper-1.0-py3-none-any.whl | Python 3 | none | any | Details for morphapiwrapper-1.0-py3-none-any.whl |
Total release size: 11.4 kB
Release files / morphapiwrapper-1.0.tar.gz
| Download URL | morphapiwrapper-1.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
852cce78858331d523899d1b94811e0bd39f235245f48fca08d62d398404d9cf
|
|
BLAKE2b-256 checksum How to use checksums |
0ffe599e2e71b040a823f452a741dfee0cb589f3355e3ba1dcd8174a193e2800
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.9
|
Release files / morphapiwrapper-1.0-py3-none-any.whl
| Download URL | morphapiwrapper-1.0-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a49e394f42342be8930e0b0b16f44cdfd42dbbb56b42e5b9f2f2000b2540463d
|
|
BLAKE2b-256 checksum How to use checksums |
ad80c5826525f8e15a3bb0292bf3f7382a53cfc58ca9218edc9919c5b65f7b9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.7.9
|
Security for morphapiwrapper 1.0
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.