I had been writing pages / scenes which were building / changing .JSON files, then getting to file using an Anchor tag / click method. This is just too limiting, especially when running on an XR headset. There it writes to a downloads directory of the device, and you have to hook up a USB connection with a pc and transfer the file using File Explorer. Way too tedious.
I am using an apache web server that does not seem to allow PUT requests, even with a .htaccess file. There is very little on the subject, other than stuff that is 10 - 20 years old saying that Apache requires a CGI script to implement them. Not messing with Perl, so am taking another tact.
Node.js has a http module that can serve requests, & I already have Node.js installed for Typescript. Was wondering if anyone knows:
Can this be capable of supporting PUT?
Is there a repo around that people are using that I can use as a starting point? I do not want to recreate the wheel.
The stuff I have seen so far is of the hello world tutorial flavor
BTW, I am not planning on hosting these pages on the open Internet.
Hey @JCPalmer - there’s probably too many different options out there, and the https requirement complicates things a bit.
Here are a couple options:
Set up an Express server (node package)
create a simple Kestrel server (generate/manage using dotnet . It’s relatively easy to set up and trust a self signed certificate
Naturally, either way you’ll still need to write code on the server side to handle saving the file and responding to the PUT request. One option I’ve used in the past is to use containers. You can spin up a docker container image of either of the above (or another web server) with a volume bind mounted to the uploads directory and all you need to supply is the PUT handler more or less.
Depending how ephemeral you want it to be, my favorite way for local hacking is serve - npm. It’s nice because you can just run it on whatever directory.
Thanks, that gives me better ideas. @br-matt, I am going to explore serve npm first. Thinking I am going to try to clone the repo, make the bare minimum changes for PUT, test, commit, then push.
Use postman to PUT at: http://localhost:3000/putdemo
Send in payload:
{
“user_id”: “brig”,
“token”: “mytoken”,
“geo”: “samplegeo”
}
Thanks guys. About an hour after my last post on Thursday, I noticed there wasn’t a
switch (requestType) {
case 'GET':
...
in serve - npm. That made me want to switch over & get a better look at the Express suggestion that I had made 2nd, because I saw the word .net.
Before I did that, thought I might need a book on Node JS, and saw there was an O’Reilly specifically on Express. I ordered it, & put this effort on hold. It gets here today.