' Module main
Sub Process_Globals
Public srvr As Server
End Sub
Sub AppStart (Args() As String)
srvr.Initialize("srvr")
srvr.AddHandler("/traiter", "traiterIOT",False)
srvr.Start
StartMessageLoop
End Sub
'Module de classe Server Handler : traiterIOT
Sub Class_Globals
End Sub
Public Sub Initialize
End Sub
Sub Handle(req As ServletRequest, resp As ServletResponse)
' exemple récupération de 3 paramètres du post passés dans une structure JSON
Dim jp As JSONParser
Dim data() As Byte = Bit.InputStreamToBytes(req.InputStream)
jp.Initialize(BytesToString(data, 0, data.Length, "UTF8"))
Dim json As Map = jp.NextObject
Dim optionsearch As Boolean = json.Get("optionsearch")
Dim language As String = json.Get("language")
Dim distance As Int = json.Get("distance")
' traiter la requête
' exemple de retour de la requête
resp.contentType = "text/plain"
resp.Write("ok")
End sub