Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion Build Automation.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Begin BuildStepList Linux
Begin BuildProjectStep Build
End
Begin CopyFilesBuildStep CopyFilesLinux
AppliesTo = 0
Architecture = 0
Target = 0
Destination = 1
Subdirectory =
FolderItem = Li4vaHRkb2NzLw==
FolderItem = Li4vZGF0YS8=
FolderItem = Li4vY2VydGlmaWNhdGVzLw==
End
End
Begin BuildStepList Mac OS X
Begin BuildProjectStep Build
Expand All @@ -10,7 +20,7 @@
AppliesTo = 0
Architecture = 0
Target = 0
Destination = 0
Destination = 1
Subdirectory =
FolderItem = Li4vaHRkb2NzLw==
FolderItem = Li4vZGF0YS8=
Expand All @@ -23,5 +33,15 @@
Begin BuildStepList Windows
Begin BuildProjectStep Build
End
Begin CopyFilesBuildStep CopyFilesWindows
AppliesTo = 0
Architecture = 0
Target = 0
Destination = 1
Subdirectory =
FolderItem = Li4vaHRkb2NzLw==
FolderItem = Li4vZGF0YS8=
FolderItem = Li4vY2VydGlmaWNhdGVzLw==
End
End
#tag EndBuildAutomation
9 changes: 1 addition & 8 deletions Demos/DemoCaching.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Protected Module DemoCaching
Sub RequestProcess(request As Express.Request)
// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
request.StaticPath = App.ExecutableFile.Parent.Parent.Child("htdocs").Child("demo-caching")
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-caching")

// If this is a request for the root.
If request.Path = "/" or request.Path = "/index.html" Then
Expand All @@ -32,13 +32,6 @@ Protected Module DemoCaching

End If








End Sub
#tag EndMethod

Expand Down
15 changes: 11 additions & 4 deletions Demos/DemoCaching/DrummersList.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Protected Class DrummersList
/// Opens a connection to the SQLite database.

// Create a folderitem that points to the database file.
DatabaseFile = App.ExecutableFile.Parent.Parent.Child("data").Child("drummers.sqlite")
DatabaseFile = SpecialFolder.Resources.Child("data").Child("drummers.sqlite")

// Create a new database instance.
Database = New SQLiteDatabase
Expand Down Expand Up @@ -55,8 +55,15 @@ Protected Class DrummersList

#tag Method, Flags = &h0
Sub DrummersGet()
// Server could be Nil if stopped
Var serverInstance As Express.Server = Request.Server
If (serverInstance = Nil) Then
Request.Response.Status = "500"
Return
End If

// Try to get the data from the cache.
Var cacheEntry As Dictionary = Request.Server.CacheEngine.Get("Drummers")
Var cacheEntry As Dictionary = serverInstance.CacheEngine.Get("Drummers")

// If cached data is available.
If cacheEntry <> Nil Then
Expand Down Expand Up @@ -88,10 +95,10 @@ Protected Class DrummersList
Drummers = Express.RowSetToJSONItem(Records)

// Cache the data.
Request.Server.CacheEngine.Put("Drummers", Drummers, 300)
serverInstance.CacheEngine.Put("Drummers", Drummers, 300)

// Get the cache entry so that we have access to its expiration.
cacheEntry = Request.Server.CacheEngine.Get("Drummers")
cacheEntry = serverInstance.CacheEngine.Get("Drummers")
CacheExpiration = cacheEntry.Value("Expiration")


Expand Down
5 changes: 2 additions & 3 deletions Demos/DemoHelloWorld.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Protected Module DemoHelloWorld
Sub RequestProcess(request As Express.Request)
// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
request.StaticPath = App.ExecutableFile.Parent.Parent.Child("htdocs").Child("demo-hello-world")
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-hello-world")

// If the request was for the "/hello" path.
If request.Path = "/hello" Then
Expand Down Expand Up @@ -45,14 +45,13 @@ Protected Module DemoHelloWorld

End If



End Sub
#tag EndMethod

#tag Method, Flags = &h0
Sub SimplePlainTextResponse(request As Express.Request)
request.Response.Content = "Hello, world!"

End Sub
#tag EndMethod

Expand Down
30 changes: 17 additions & 13 deletions Demos/DemoMultipartForms.xojo_code
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
#tag Module
Protected Module DemoMultipartForms
#tag CompatibilityFlags = ( TargetConsole and ( Target32Bit or Target64Bit ) ) or ( TargetWeb and ( Target32Bit or Target64Bit ) ) or ( TargetDesktop and ( Target32Bit or Target64Bit ) ) or ( TargetIOS and ( Target32Bit or Target64Bit ) )
#tag Method, Flags = &h21
Private Function GetOrCreateUploadsFolder() As FolderItem
Var base As FolderItem = SpecialFolder.Desktop
If (base = Nil) Or (Not base.IsFolder) Or (Not base.Exists) Then
base = SpecialFolder.UserHome
End If

base = base.Child("express-demo-uploads")
If (Not base.Exists) Then base.CreateFolder

Return base

End Function
#tag EndMethod

#tag Method, Flags = &h0
Sub RequestProcess(request As Express.Request)
#Pragma Warning "TODO: There is a bug in this demo. I can't get it to work as is"
' Not sure if it's to do with browser pre-fetching resources?

// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
request.StaticPath = App.ExecutableFile.Parent.Parent.Child("htdocs").Child("demo-multipart-forms")
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-multipart-forms")

// If content has been posted...
If request.Method = "POST" Then
Expand All @@ -17,7 +29,7 @@ Protected Module DemoMultipartForms
Var fp As New FormProcessor(request)

// This is the folder that files will be uploaded to.
fp.UploadFolder = App.ExecutableFile.Parent.Parent.Child("uploads")
fp.UploadFolder = GetOrCreateUploadsFolder

// This is an optional prefix that will be added to files that are saved.
'fp.FilenamePrefix = Express.UUIDGenerate
Expand Down Expand Up @@ -56,14 +68,6 @@ Protected Module DemoMultipartForms

End If









End Sub
#tag EndMethod

Expand Down
2 changes: 2 additions & 0 deletions Demos/DemoServerThreads.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Protected Module DemoServerThreads
Request.Response.Status = "501 Not Implemented"
Request.Response.Content = "The server is not configured to handle requests on port " + Request.Port.ToString + "."
End If

End Sub
#tag EndMethod

Expand Down Expand Up @@ -48,6 +49,7 @@ Protected Module DemoServerThreads
While True
App.DoEvents
Wend

End Sub
#tag EndMethod

Expand Down
7 changes: 1 addition & 6 deletions Demos/DemoSessions.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Protected Module DemoSessions
Sub RequestProcess(request As Express.Request)
// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
request.StaticPath = App.ExecutableFile.Parent.Child("htdocs").Child("demo-sessions")
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-sessions")

// If this is a request for the root...
If request.Path = "/" or request.Path = "/index.html" Then
Expand Down Expand Up @@ -53,11 +53,6 @@ Protected Module DemoSessions

End If






End Sub
#tag EndMethod

Expand Down
12 changes: 9 additions & 3 deletions Demos/DemoSessions/Sessions.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ Protected Class Sessions

#tag Method, Flags = &h0, CompatibilityFlags = (TargetConsole and (Target32Bit or Target64Bit)) or (TargetWeb and (Target32Bit or Target64Bit)) or (TargetDesktop and (Target32Bit or Target64Bit)) or (TargetIOS and (Target32Bit or Target64Bit))
Sub TableGenerate()
// Generates an HTML table to display the sessions that SessionEngineAE is managing.
// Server could be Nil if stopped
Var serverInstance As Express.Server = Request.Server
If (serverInstance = Nil) Then
Request.Response.Status = "500"
Return
End If

// Generates an HTML table to display the sessions that SessionEngineAE is managing.

// Open a table.
TableHTML = "" _
Expand All @@ -85,11 +91,11 @@ Protected Class Sessions


// Loop over the server's session keys...
For Each key As Variant in Request.Server.SessionEngine.Sessions.Keys
For Each key As Variant In serverInstance.SessionEngine.Sessions.Keys

// Get the entry's key and value.
Var sessionID As String = key
Var session As Dictionary = Request.Server.SessionEngine.Sessions.Value(key)
Var session As Dictionary = serverInstance.SessionEngine.Sessions.Value(key)

Var remoteAddress As String = session.Lookup("RemoteAddress", "")
Var username As String = session.Lookup("Username", "n/a")
Expand Down
15 changes: 3 additions & 12 deletions Demos/DemoTemplatesClientSide.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ Protected Module DemoTemplatesClientSide
Sub RequestProcess(request As Express.Request)
// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
#If DebugBuild Then
request.StaticPath = App.ExecutableFile.Parent.Parent.Child("htdocs").Child("demo-templates-client-side")
#Else
request.StaticPath = App.ExecutableFile.Parent.Child("htdocs").Child("demo-templates-client-side")
#EndIf
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-templates-client-side")

// Process the request based on the path of the requested resource...
If request.Path = "/data" Then
Expand All @@ -18,12 +14,7 @@ Protected Module DemoTemplatesClientSide
'Thread.SleepCurrent(10)

// Get the orders.
Var orders As String
#If DebugBuild Then
orders = Express.FileRead(request.StaticPath.Parent.Parent.Child("data").Child("orders.json"))
#Else
Orders = Express.FileRead(request.StaticPath.Parent.Child("data").Child("orders.json"))
#EndIf
Var orders As String = Express.FileRead(request.StaticPath.Parent.Parent.Child("data").Child("orders.json"))

Try

Expand Down Expand Up @@ -107,7 +98,7 @@ Protected Module DemoTemplatesClientSide
// Add the Request object.
Var requestData As New Dictionary
requestData.Value("cookies") = request.Cookies
requestData.Value("data") = request.Data
requestData.Value("data") = request.Body
requestData.Value("get") = request.GET
requestData.Value("headers") = request.Headers
requestData.Value("method") = request.Method
Expand Down
2 changes: 1 addition & 1 deletion Demos/DemoTemplatesServerSide.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Protected Module DemoTemplatesServerSide
Sub RequestProcess(request As Express.Request)
// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
request.StaticPath = App.ExecutableFile.Parent.Parent.Child("htdocs").Child("demo-templates-server-side")
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-templates-server-side")

// Process the request based on the path of the requested resource...
If request.Path = "/" or request.Path = "/index.html" Then
Expand Down
2 changes: 1 addition & 1 deletion Demos/DemoWebSockets.xojo_code
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Protected Module DemoWebSockets
Sub RequestProcess(request As Express.Request)
// By default, the Request.StaticPath points to an "htdocs" folder.
// In this example, we're using an alternate folder.
request.StaticPath = App.ExecutableFile.Parent.Parent.Child("htdocs").Child("demo-websockets")
request.StaticPath = SpecialFolder.Resources.Child("htdocs").Child("demo-websockets")

// If the request was for the "/chat" path...
If request.Path = "/chat" Then
Expand Down
Loading