Skip to content

idomoz/rpc-over-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPC over HTTP

This is a simple JavaScript library for promised RPC over HTTP implemented with python Backend.

  • Easy to use.
  • Eases Frontend development.

Installation

  • Add server.js to Frontend directory.
  • Add app.py to Backend directory.
  • Create a file called api.py in your Backend directory and add some functions:
    def login(username, password, request):
        if username == 'foo' and password == 'bar':
            return 'correct credentials'
        return 'forbidden'
    the request object is passed to evey function by app.py. (For more examples see api.py)
  • Add populate.py to your scripts directory and change any relevant paths inside it.

Usage

  • Every time you add a new function to api.py, run populate.py so you could use it in your Frontend code.
  • Once populated, import server:
    import server from 'server'
    then call one of your server functions:
    server.login('foo', 'bar');
    or if the function returns something:
    server.get_some_data().then(response =>{
        console.log(response.data);
    });
    (For more examples see index.js.)
  • Because the functions are populated, most IDEs will suggest the arguments every function takes, which minimizes mistakes: screenshot

Dependencies

Enjoy! 😃

About

A simple JavaScript RPC client implemented with python Backend

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy