idle wrote: Tue Mar 12, 2024 9:07 pm
fixed so it will warn you if no www directory exists
This didn't happen for me just now — I created an index.html file in the folder of the server, which the server ignored, although its status window showed "Server Running on port 80" and then "Client IP x.x.x.x load index.html client 33984320", suggesting it had found the file "index.html", but in fact it hadn't.
When I realised my mistake and put the index.html file inside a www sub-folder, it worked, but I didn't see an error beforehand.
it's got an internal index.html and error.html so it will show those if it can't find the specified www/ folder
so
1) you need to create a subfolder in the source directory "www" and the put assets there
2) compile the temp exe in the source folder
but if it doesn't find them it will display the internal html.index "under construction" or Errror.html or a valid uri handler http://127.0.0.1/foo?foo=1234&bar=5678
idle wrote: Tue Mar 12, 2024 9:07 pm
fixed so it will warn you if no www directory exists
This didn't happen for me just now — I created an index.html file in the folder of the server, which the server ignored, although its status window showed "Server Running on port 80" and then "Client IP x.x.x.x load index.html client 33984320", suggesting it had found the file "index.html", but in fact it hadn't.
When I realised my mistake and put the index.html file inside a www sub-folder, it worked, but I didn't see an error beforehand.
it's got an internal index.html and error.html so it will show those if it can't find the specified www/ folder
so
1) you need to create a subfolder in the source directory "www" and the put assets there
2) compile the temp exe in the source folder
but if it doesn't find them it will display the internal html.index "under construction" or Errror.html or a valid uri handler http://127.0.0.1/foo?foo=1234&bar=5678
Thanks for the reply Idle. It isn't doing that though, when I wrongly set it up and accidentally omitted the www sub-folder. The client browser just displays the default "under construction", not an error.
Anyway, it's working fine, so long as I put the necessary files into www. I'd expected an error, because of the comment "... it will warn you if no www directory exists".
Incidentally just to add to this, my interest relates to its possible use as a front-end to a PureBasic application. I have no idea how practical that might be.
That is the desired behavior the display message was before I added the handlers so I put rhe warning in but it's not needed now it's just a default urihandler.
The next addition will be an optional virtual file system which is the same contents as your www so once your application is ready you just packit and add the pack to the datasection.
This works well if you have js frameworks so it ideal for deploying or hosting spiderbasic applications for instance.
idle wrote: Fri Mar 15, 2024 8:44 pm
The next addition will be an optional virtual file system which is the same contents as your www so once your application is ready you just packit and add the pack to the datasection.
This works well if you have js frameworks so it ideal for deploying or hosting spiderbasic applications for instance.
Interesting, I see what you're intending to do now. Does a SpiderBasic app need only to be installed at the server side? SpiderBasic has been a bit of a mystery in terms of where it fits exactly. I asked about SpiderBasic (specifically, is it a web server) when I bought a copy of PB but I didn't really get much information.
spiderbasic web applications need a server to run on. Unless it's changed the spider basic compiler uses an embedded mongoose server to run your apps.
My intent is to provide a simple solution to test and host an application as a server with no dependencies, I'm essentially replacing the basic functionality of civetweb (forked from mongoose) in my civetserver project, so that it's cross platform but it's not designed to be a full blown server just a quick, easy and flexible module to use as a component.
Procedure CBUri(*request.Atomic_Server_client,*contentType)
;do anything here And return a databuffer To be served
;Select *request\RequestedFile
;ForEach *request\parameters() you have access to all the variables
;set contentType
;return *data
EndProcedure
Procedure CBPost(*request.Atomic_Server_client)
;you have access to all the variables
;use a select on the *request\RequestedFile
EndProcedure
Procedure CBGet(*request.Atomic_Server_client)
;you have access to all the variables
;use a select on the *request\RequestedFile
EndProcedure
;to host static and dynamic urls where endpoints are arbitary
Atomic_Server_Init("My Atomic Webserver",80,"www/",@CBPost(),@CBGet())
Atomic_Server_start(0) ;no window
Atomic_Server_Add_Handler("foo",@CBURI()) ;<- add a handler fuction dynamicly even at runtime
Repeat
Until quit
Atomic_Server_Exit()
skinkairewalker wrote: Mon Mar 18, 2024 7:14 pm
I'm trying to add several servers to test, and only the last one created listens to the request, the other previous ones stop listening.
It will be a thread issue, it'll be clobbering some memory, the change to make it run on multiple IP's will have likely introduced side effects and I haven't written a test case for those changes yet nor had the time to debug it and I'm only testing it on windows at the moment.
3.0.5a
bug fix, seems I was missing #PB_File_SharedRead on file access, despite being led on a wild goose chase
note to self make sure #PB_File_SharedRead is set on threaded file access.
the purifier stated overflow in string memory block but the crash location was totally random.
I haven't tested it on Linux or osx so don't know if it's a problem. if it is I will have to reconsider how I do it.
I'm trying to keep it simple and the threading model I chose makes it lock free from the user point of view.
one thread per server many threads per request which can be done in parallel without locks.
I would expect threadsafe would call the appropriate file read() function on linux osx, flockread()
the bug in windows was hard to find as there was no useful information just that it was overflowing a string buffer
or I got an IMA with a constant address.
as far as I was aware #PB_File_SharedRead is for across process access maybe that should state across threads / process
if the file has been already opened by another process for read operation, this flag is needed to access it (Windows only).
v3.05b
Rearranged a bit and added persistence for clients with timeout in preparation for adding SSL, clients sill spawn multiple threads so might add a thread pool later but for now it's still spawn a thread per request so the server can deal with multiple clients making multiple async requests with minimal blocks.