WebPage.Show from HandleURL

I have to admit this is not clear at all.

Let me see : you do not want to use any Xojo WebPage at all ? Is that it ?

Then why go through the Xojo web app ? Why not point directly to the file ? Then it would be http://localhost/index.html, would it not ?

[quote=292830:@Michel Bujardet]I have to admit this is not clear at all.
Let me see : you do not want to use any Xojo WebPage at all ? Is that it ?
Then why go through the Xojo web app ? Why not point directly to the file ? Then it would be http://localhost/index.html, would it not ?[/quote]

In this case I am trying to retrieve html files without help from a different/external web server, because I want to be a standalone executable web server for windows. I’ll show external files (view layer), and I’ll have a Xojo WebPage to show results, using embedded iframe. That’s what he intended to do in this case. The load and display files, and iframe load I already have done.

Manuel, what I don’t understand is why you want to use http://localhost:8080, which is the URL of the main WebPage of the application, to display an HTML page.

It would be a lot preferable to keep that URL for the app WebPages (standard UI).

Something like http://localhost:8080/html/ would seem a lot more appropriate to serve a set of html files, or even an entire site.

Here is a project I created a couple years ago that serves an entire web site through HandleSpecialURL.
websitethroughspecial.xojo_binary_project

For use, point to the root of your local html pages (in my project it was matchfonts.com), run the app, and point your browser to the index page as such :

http://127.0..1:8080/Special/index.html[/code] or [code]http://127.0..1:8080/api/index.html

At the time HandleURL did not exist, but the principle is exactly the same. This way you can serve HTML pages through a standalone app.

Thanks, Michel. But… Why not? What prevents it? A convention on ways of working? Or is there some security reason?

One reason could be that I like playing cluelessness :wink: And i like to use virtual root directory.

I see only one drawback, and I do not know if it’s because I’m using this method. The iframe takes longer to load than the rest of the page. Does this always happen?

The Xojo Web standalone app will serve the default WebPage to that address. If you ever need to use the regular session system, short circuiting it in HandleURL will prevent it.

It is always a good idea to avoid making such evolutions impossible.

For the iFrame, don’t forget you are in fact loading two pages. That can take longer if their have big pictures, or a lot of them.

[quote=292880:@Michel Bujardet]The Xojo Web standalone app will serve the default WebPage to that address. If you ever need to use the regular session system, short circuiting it in HandleURL will prevent it.
It is always a good idea to avoid making such evolutions impossible.
For the iFrame, don’t forget you are in fact loading two pages. That can take longer if their have big pictures, or a lot of them.[/quote]

Thanks Michel, but so far would not even know how to use a system of regular sessions. I have it present, and in any case is easily corrected by inserting a directory path.

I think I know why it takes longer. Webpage under Xojo takes longer to load than when loading a html file …

Do as you want. I will have warned you. And, no, you cannot change directory for a Xojo standalone web app, so when the time come, you may learn the lesson by being burnt. Well, if that is what it takes, it will be you own doing.

And yes, going through a WebFile in a standalone app does take longer than a simple Apache request.

Michel, I will follow his recommendations. I already have enough problems to solve … Thank you for your great support :slight_smile:

I found a solid way to get to a Xojo Web Page from HandleURL or HandleSpecialURL and pass along a value. An example would be:

http://127.0.0.1:8080/SignQuote/123

In the code below, you’ll see app.CookieSignQuote which is a string constant that would be equal to ‘SignQuote’.

This goes into either app.HandleURL or app.HandleSpecialURL, depending on if you want to include /api/ or /special/ in your URL. The first bit of code converts Request.Path to an array. The second part looks at request to see if it can handle it. If so, it sets a cookie with the invoice number and the redirects the user to the root of the Web App which would pass control to the WebSession.

[code]////////////////////////////////////////
// Get the Request Path as an Array
dim theRequestValues() as string
theRequestValues = split( Request.Path, “/” )

////////////////////////////////////////
// Respond to /example/sometext
If theRequestValues.Ubound = 1 Then
If theRequestValues(0) = app.CookieSignQuote and theRequestValues(1) <> “” Then
Request.SetCookie( app.CookieSignQuote, theRequestValues(1) )
Request.Header( “Location” ) = “/”
Request.Status = 302
return True
End If
End If[/code]

Then in Session.Open, you look for the cookie and do something with its value.

//////////////////////////////////////////////////////// // If the CookieNameExample is set... Dim QuoteNum As String = Cookies.Value( app.CookieSignQuote ).StringToText If QuoteNum.IsNotEmpty Then Cookies.Remove( app.CookieExample ) QuoteSignPage.QuoteNum.Text = QuoteNum QuoteSignPage.show Return End If

Hal, Thanks that worked perfectly