Web Apps On local browser and server

I am building a new application that will need to run on a server for remote browser access, and also on a local browser. I have a file that I will want to save in either case and an existing file that I will need to access in either case. I think I get the file access when running from a server, but not so much when running on a local browser.

Is there a method to determine if the app is operating from a local browser or a server? And, how do I save the file or open the existing file when running from the local browser?

[quote=138811:@Larry Cluchey]I am building a new application that will need to run on a server for remote browser access, and also on a local browser. I have a file that I will want to save in either case and an existing file that I will need to access in either case. I think I get the file access when running from a server, but not so much when running on a local browser.

Is there a method to determine if the app is operating from a local browser or a server? And, how do I save the file or open the existing file when running from the local browser?[/quote]

Your post is confusing. Let me see if I understand :

  • You have one app that you intend to run both on a host or locally. I guess you will run the local file as standalone the same way as the debug run.
  • You want to save a file from your app. Where does it come from ? Upload ? Internally generated from data input ?
  • This app needs access to an existing file. No difference between a local run and remote. Just use FolderItem.

I am not so sure I did understand, because your expression “run from the local browser” is kind of unclear.

The local app will be accessed through http://127.0.0.1:8080 (or other port) or locahost. You can test for that.

Also, the local app could be Mac OS X or Windows when most of the time a host will require Linux. This can be tested as well.

The file I want to save is generated internally. Everything else is OK

All you got to do is to use a folderitem to write with a TextOutputStream or BinaryStream wherever you need to in the file system where your app is executed. Or is there anything else ?

Is there a way to determine if the app is running on a server or local desk top? I apologize for being thick on the file I/O issues. I guess I am confused on how to write a file to a remote server and/or write it to a local host/browser. The URL’s would be different, right?

What is your desktop ? Mac, Windows, Linux ? What is your host ? Windows ? Linux ? That is how it will be possible to know. Tell me more and I will be able to help.

Saving a file on a server is no different than on any other machine. See http://documentation.xojo.com/index.php/FolderItem and TextOutputStream or BinaryStream. SpecialFolder.ApplicattionData is usually where you will store your files. See http://documentation.xojo.com/index.php/SpecialFolder

Does it matter what platform is running the app in local mode? I would guess Windows for most of the users. I don’t know at the moment what the host is running.

I am asking because that is one of the ways you can tell if the app is running on the server. The other way is to look at the current URL. If it is localhost or something else.

Thanks Michel. I am going to experiment and see what works for me. I will most likely have to come back and ask some other questions.

Michel,

I have bought the license for Web builds for my project. I built it and trued to run it with no success. I get the .exe file and when clicked I get the running window. I try to open the app in a browser and it comes back with can’t open. I used ipconfig to get my ipaddress and entered that while the app window was running.

Where am I going off track?

Remember that all code for web apps runs on the server. There is no ‘local’ app. It’s all on the server and the browser is just a window showing you what’s on the server.

In the WebSession there is a property for RemoteAddress. WebSession is about the only place where anything about the end browser can be found. IP Address, Browser Type, and a few other things , but not much.

If you are running it debug on a local machine, the address you put in your browser is http://127.0.0.1:8080. If you are running it on another machine you need to use the IP address of that machine AND the port you’ve specified in the build settings.

[quote=141582:@Larry Cluchey]Michel,

I have bought the license for Web builds for my project. I built it and trued to run it with no success. I get the .exe file and when clicked I get the running window. I try to open the app in a browser and it comes back with can’t open. I used ipconfig to get my ipaddress and entered that while the app window was running.

Where am I going off track?[/quote]

When you launch your web app on your PC, it works just the same as the debug app : you must use your browser.

If you look at the Shared Build settings, you will notice that as a default, Xojo builds web apps with the port 80. If you have changed that, use the same value. Also, make sure to set deployment as Standalone. On the host, it is often cgi instead.

So to see your app locally when the app runs, open the browser and enter :

http://127.0.0.1:80