This is a simple JavaScript library for promised RPC over HTTP implemented with python Backend.
- Easy to use.
- Eases Frontend development.
- 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:thedef login(username, password, request): if username == 'foo' and password == 'bar': return 'correct credentials' return 'forbidden'
request
object is passed to evey function byapp.py
. (For more examples seeapi.py
) - Add
populate.py
to your scripts directory and change any relevant paths inside it.
- Every time you add a new function to
api.py
, runpopulate.py
so you could use it in your Frontend code. - Once populated, import server:
then call one of your server functions:
import server from 'server'
or if the function returns something:server.login('foo', 'bar');
(For more examples seeserver.get_some_data().then(response =>{ console.log(response.data); });
index.js
.) - Because the functions are populated, most IDEs will suggest the arguments every function takes, which minimizes mistakes:
Enjoy! 😃