Sub Server_HandleRequest (Request As ServletRequest, Response As ServletResponse)
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("/delete/")
SetContentType(Request.RequestURI, Response)
Dim CurrentPath As String = DecodePath(Request.RequestURI.SubString("/delete/".Length))
File.Delete(server.CurrentPath)
' ########################################################################################
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