Skip to main content

Allows you to seemingly call a server function directly from the client.

Project description

forthright

forthright is a Remote Procedure Call (RPC) package that uses Flask to allow you to call server functions from the client. It saves you the hassle of needing to pack your arguments into a json and unpack them on the server.

A simple example

# backend.py
from forthright import forthright_server
from flask import Flask

app = Flask(__name__)
frs = forthright_server(app)

def add_and_sub(numA, numB):
    return numA + numB, numA - numB

frs.register_functions(add_and_sub)

if __name__ == '__main__':
    app.run(port=8000)
# client.py
from forthright import forthright_client

url = 'http://127.0.0.1:8000'
frc = forthright_client(url)

sum, diff = frc.add_and_sub(8, 2)
print('%d %d' %(sum, diff)) # -> 10 6

Installation

pip install forthright

Limitations

You can only pass arguments by value, not by reference. For example, if an argument is a list, the server function will receive a copy of that list.

If an argument is a custom object, the class definition must be present in both the client code and the server code.

Warning: By default, this code deserializes pickled data on the server which is unsafe. There is an optional Safe Mode to instead send data with json, but this will prevent you from sending custom objects. To turn on Safe Mode, set safe_mode=True when instantiating both forthright_server and forthright_client:

frs = forthright_server(app, safe_mode=True)

frc = forthright_client(url, safe_mode=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forthright-0.0.6.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forthright-0.0.6-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file forthright-0.0.6.tar.gz.

File metadata

  • Download URL: forthright-0.0.6.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.1

File hashes

Hashes for forthright-0.0.6.tar.gz
Algorithm Hash digest
SHA256 10154c212ed6ad7c1adb7d5c413d3d5da7878e9a22ac76948ce11a8308e963d9
MD5 f5a79a192e2e4f5c42298b5ee058ea89
BLAKE2b-256 bee8ba70786586d9c00186f3f4a049e5bf867368f7bdaa6ef47e672731865537

See more details on using hashes here.

File details

Details for the file forthright-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: forthright-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.1

File hashes

Hashes for forthright-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0ab77b8d000b2d06eea73c412346671ee1dab774688be6a0915e03a7337851a4
MD5 233676282e2115156cd4304d57990e2a
BLAKE2b-256 598535080d8071cdd08e3d0eaf6fc2b3008190bd3fff84d30057030fcdc7a076

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page