You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

morphapiwrapper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

morphapiwrapper

Wrapper functions for creating APIs in Morphisdom


Maintainers
1

Readme

morphapiwrapper

Wrapper functions for creating APIs in Morphisdom

Build Status

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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc