Codea Web Server (Also on WebRepo)

@dave1707 The html source provided in the project zip above is in the project bundle itself. That’s what they’re seeing in the browser.

@Steppers I forgot about looking in assets. I see the info there. Still can’t get it to run.

I put a print statement in every function in the webserver tab. When I run the code, the only print I see is the one in the init function. I see that as soon as I run the webserver code. It’s like the Safari localhost does nothing because nothing else prints.

PS. I forgot the prints in the webserver_loop. It prints loop, and empty func, but not request.

    local function webserver_loop()
        print("loop")
        http.request("http://imnotarealurl.lua", function() print("empty func") end, function()
            print("request")
            self:_update()
            webserver_loop()
        end)
    end

essentially that pic, yes. zoomed differently.

is there some way to view the assets? is there some way to open the unzipped project as files, to see what’s in it?

thanks!

@RonJeffries I have an app called iZip (free) that I tried on the webserver.zip file. It extracted 7 files. I was able to view all 7 files right in iZip.

@RonJeffries @Steppers I don’t see the asset key that Ron shows in his image above. I see the web server running, then I see the connect at: stuff.

i may have izip, will try it. no way in codea or native ios?

@dave1707 Your problem is with webserver_loop I think.

If you change it to this does it help?

local function webserver_loop()
    tween(0.0001, {}, {}, nil, function()
        self:_update()
        webserver_loop() -- Loop again
    end)
end

If it is that then I suspect it may also be your problem too @UberGoober
Without the loop functioning nothing will work.

@Steppers That was it. After the change it worked just fine.

@RonJeffries As far as I know, Codea or iOS isn’t going to unzip the files and let you view them.

seems like, yeah,

could the problem be that short timeout?

That fix worked for me too.

@RonJeffries If you have ‘Working Copy’ you can also view them there.

@dave1707 I’m glad that helped! Let me know if this helps you too @UberGoober :smile:

The .codea files are just plain old folders (not zip files) but iOS treats any folder with an extension like a file (sometimes unhelpfully).

On Mac it at least has an option to ‘View Contents’ of these bundle folders… iOS could do with it too.

@Steppers hi noted just above your previous message that the fix worked for me too, but I am repeating that now in case it got lost in the shuffle.

The web server works now, and the debugger works now too.I’m not super clear on what’s happening here, I have to admit, but I agree it looks promising.

debugger? there’s a debugger in there? how do I invoke that? thanks!

…maybe I’m missing something, but the title of the post includes “debug server”, at least presently. Am I misunderstanding the meaning of that?

@UberGoober @RonJeffries There’s another project on WebRepo, ‘Debug Server’.

It only really provides the same functionality as the parameter.watch stuff at the moment but it’s a start.

Note: You’ll probably have to use that loop fix again for it.

And on a related note, I’ve got a lot of advanced stuff in the works now. Server side scripting akin to PHP, Multiple Client handling & websockets so I expect things to get pretty spicy soon :smile:

I made a slightly more interactive version of the Debugger.

It tracks taps and increments a “tap” variable every time a touch ends.

Also, @Steppers: I gave it a generic icon that I sometimes use for my own utilities; maybe it could be a standard icon for library-type projects? (image attached too)

A sneak peak, code needs a little tidying up but WebSockets are working!

teaser

@UberGoober Nice, I actually have a few already included in the WebRepo project that are just unicode/emoji and rendered out (also attached).