Sub Server_HandleRequest (Request As ServletRequest, Response As ServletResponse)
'add for permission:
Public rp As RuntimePermissions
rp.CheckAndRequest("READ_EXTERNAL_STORAGE")
rp.CheckAndRequest("WRITE_EXTERNAL_STORAGE")
rp.CheckAndRequest("ACCESS_FINE_LOCATION")
rp.CheckAndRequest("INTERNET")
'end add for permission
Try
Log("Client: " & Request.RemoteAddress)
Log(Request.RequestURI) 'handle the request based on the URL
Select True
Case Request.RequestURI = "/"
HandleMainPage (Response)
Case Request.RequestURI.StartsWith("/list/")
HandleList (Request, Response)
Case Request.RequestURI.StartsWith("/download/")
SetContentType(Request.RequestURI, Response)
Response.SendFile("", DecodePath(Request.RequestURI.SubString(9)))
Case Request.RequestURI.StartsWith("/upload/")
HandleUpload(Request, Response)
Case Else
'send a file as a response (this section is enough in order to host a site)
SetContentType(Request.RequestURI, Response)
Response.SendFile(File.DirAssets, DecodePath(Request.RequestURI.SubString(1)))
End Select
Catch
Response.Status = 500
Log("Error serving request: " & LastException)
Response.SendString("Error serving request: " & LastException)
End Try
End Sub