Web app on Mac personal web sharing

Just wondering : would it be possible to run a web app in the Mac personal web sharing ? How would one go about it ?

http://www.cnet.com/how-to/how-to-enable-web-sharing-in-os-x-mountain-lion/

I think this would get you going! Wish you success!

[quote=88972:@Andre Kuiper]http://www.cnet.com/how-to/how-to-enable-web-sharing-in-os-x-mountain-lion/

I think this would get you going! Wish you success![/quote]

Thank you Andre. I already know how to activate the personal web sharing for HTML.

Since my post, I did find how to activate CGI for it at:
http://www.macdevcenter.com/pub/a/mac/2001/12/14/apache_two.html

I can’t imagine a scenario where one might be tempted to use PWS where a stand-alone deployment on that Mac wouldn’t be easier and better. But I have no imagination today, so YMMV.

My imagination maybe limited by lack of knowledge, and I would love to be enlightened. I never used standalone Web apps anywhere. Just CGI. So, if this is possible, could you please be so kind to teach me step by step how to run a standalone app on the Mac and make it available through a local network to other computers ?

Thank you in advance.

I’ll give you a rough outline. Expanding each into detail is a good 2 to 3 hours of training.

  1. Build standalone app.
  2. Run from Terminal, e.g.

cd [path to MyApp] ./MyApp --port=3000 --maxSockets=100 &
or
Create a certificate file in same directory as MyApp.

      ./MyApp --securePort=3000 --maxSecureSockets=100 &
  1. Open port 3000 in any firewall you have, and/or port forward from your router.

HTH.

Thank you. Followed your outline with a program called weblistbox built as standalone…

[2] 1621 [1] Exit 126 ./weblistbox --port=80 --maxsockets=100 Mitchs-iMac:weblistbox Mitch$ -bash: ./weblistbox: cannot execute binary file

weblistbox is set as chmod 755…
Did you say it was easy ?

I think I said “easier”. One note… you’ll need to be root to serve on ports <= 1023. Did you build for Mac OS X? You’d get a similar error if you tried to run the Linux binary on OS X I think.

OK. Easier. Got it. Thank you. I had built for Linux. Built again for Mac this time, and the program launched.

Now I have the process running. But how do I access the web app ?

With http://192.168.1.34:80 which is the IP of my Mac or 127.0.0.1:80 all I access is the personal web sharing index.html :frowning:

The default port for stand-alone webapps is 8080, did you change it to 80?
Both ip-numbers should work and also the name ‘localhost’.

[quote=89013:@Andre Kuiper]The default port for stand-alone webapps is 8080, did you change it to 80?
Both ip-numbers should work and also the name ‘localhost’.[/quote]

I have now changed to 8080 and access the app through http://127.0.0.1:8080 and http://192.168.1.34:80 from other computers :slight_smile:

it is indeed easier than setting up WPS Apache for cgi-bin, I had to understand the steps involved.

Thank you for your help.

Then you were a victim of the < 1024 port number barriere of Apple :wink: . Glad to hear it works. :smiley:

[quote=89014:@Michel Bujardet]I have now changed to 8080 and access the app through http://127.0.0.1:8080 and http://192.168.1.34:80 from other computers :slight_smile:

it is indeed easier than setting up WPS Apache for cgi-bin, I had to understand the steps involved.

Thank you for your help.
[/quote]

I have found that time is better spent by most getting over this hurdle than dealing with the can of worms that the “ease” of cgi deployments opens up, regardless of platform. But yeah, it’s a hurdle.

My experience with cgi came from perl on a host, and I quite naturally deployed cgi over my web sites. Lucky I was that my VPS readily took Xojo web apps, and afterward that 1701 came along. So I never had to wonder about standalone.

Now, I still have a question : is it possible to access a standalone app without explicitly enter the port number ?

[quote=89030:@Michel Bujardet]Now, I still have a question : is it possible to access a standalone app without explicitly enter the port number ?
[/quote]

Sure, create a “wrapper” page (PHP/HTML) and embed the app in a frame. The frame could even take up the whole page, so visually, the user would have no idea what’s going on. Serve the main page with a traditional web server. You can use this technique to do rudimentary (but surprisingly effective) load balancing or to provide a recognizable branded URL to distinguish multiple systems.

If you use HTTPS, you’ll need to research and handle modern browser frame security rules. Small hassle.

[quote=89088:@Brad Hutchings]Sure, create a “wrapper” page (PHP/HTML) and embed the app in a frame. The frame could even take up the whole page, so visually, the user would have no idea what’s going on. Serve the main page with a traditional web server. You can use this technique to do rudimentary (but surprisingly effective) load balancing or to provide a recognizable branded URL to distinguish multiple systems.

If you use HTTPS, you’ll need to research and handle modern browser frame security rules. Small hassle.[/quote]

Thanks :slight_smile:

AFAIK: This is no “Apple Barriere”. Ports between 0 and 1023 are so called “well known ports” (WKP’s) and will be “blocked” by most OS’s. :wink:

AFAIK i haven’t seen that on Windows or Linux. On Windows and Linux it’s just a matter of settings in the firewall. On a Mac you have to run as root to use those ports (again AFAIK).

Thanks to Andre’s guidance in the Windows thread about running a standalone app for local access, I know now that a web app contains its own server, and that Personal Web Sharing is not even necessary.

What I notice, though, is that the terminal must remain opened after launching the app for it to stay active.

A standalone webapp is a console program without a gui. If you close the console your webapp-webserver dies with it. On windows it can run as a service. The problem with a standalone webapp is that when it crashes it doesn´t restart automatically as a cgi/webapp does.
For easy testing and setting up webapps i often use the Abyss webserver from http://www.aprelium.com/abyssws/
This webserver is available for Mac, Windows and Linux and the x1 version is free. The only limitation i know for the x1 version is that it only supports one domain. It fully supports cgi webapps.