PB app as a HTTP Rest API

Just starting out? Need help? Post your questions and find answers here.
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

PB app as a HTTP Rest API

Post by lesserpanda »

Hello guys,

I'm looking at how to get PB to become a HTTP Rest API endpoint but not sure where to start. I've seen the CGI module but that is kind of one endpoint and using variables like abc.net/cgi-bin/app?action=abc and then run procedures based on that.

Looking to build a backend for my SpiderBasic app.

Or maybe a websocket is better to do? Please advise your experience?
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PB app as a HTTP Rest API

Post by infratec »

With a REST-API endpoint you mean a web server which reponds to your JSON requests.

So you need to implement a server which listens to port 80 (or whatever) and handle the incoming packets.
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Re: PB app as a HTTP Rest API

Post by Marc56us »

If your application uses SpiderBasic, then there is already a web server. So you have to use the CGI system.
It is the equivalent of a console application, except that the standard output is the Web page and not the console.
Nothing special to do, except format the output (web page ? json ? xml ? text ?)
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB app as a HTTP Rest API

Post by Fred »

You can use Websocket (available in the new SpiderBasic 2.40 version) and for the server, using this module: https://github.com/Dadido3/WebSocket_Server. It should be easy to do an fast.
User avatar
blueb
Addict
Addict
Posts: 1041
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: PB app as a HTTP Rest API

Post by blueb »

Hi Fred,
Very interested in v2.40 as I'm interested in Android apps. :)

And you say...
beta 4 is out, it includes AAB (Android App Bundle) package creation and some fixes to be able to publish on Google Play. I tried it and it works as expected. An AAB package will be now automatically generated when creating an Android app which is not in debug mode. Feel free to test it to see if it works as expected !
- It was too lonely at the top.

System : PB 6.10 Beta 9 (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply