Write HTTP Server for 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

Write HTTP Server for API

Post by lesserpanda »

Hi guys,

I've done a simple exe based on the example and ran it as a CGI In IIS. This works.

However, I'm trying to see if I can do a HTTP POST to it instead of just a GET. Or for that matter, other http requests type.

Here's the example I'm using.

Code: Select all

If Not InitCGI() Or Not ReadCGI() 
  End
EndIf

WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader) ; Write the headers to inform the browser of the content format

WriteCGIString("<html><title>PureBasic CGI</title><body>Test</body></html>")
What I'm trying to do is just have a HTTP Server running and then actioning stuff based on the paths provided. Much like gorilla/mux in golang.
https://github.com/gorilla/mux
infratec
Always Here
Always Here
Posts: 7579
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Write HTTP Server for API

Post by infratec »

Sorry, but your code has nothing to do with a http server.

Today an API is mots a REST-API which don't use CGI.It uses normal GET,POST, PUT ... requests.
Look at the atomic server in Examples/Sources - Advanced'

In general you need a network server which processes the requests.
lesserpanda
User
User
Posts: 65
Joined: Tue Feb 11, 2020 7:50 am

Re: Write HTTP Server for API

Post by lesserpanda »

Oh perfect. That's what I was after.

Thank you very much for your direction as always!
Post Reply