Page 3 of 3 FirstFirst 123
Results 81 to 105 of 105

Thread: VB6 Web Site/App Server

  1. #81

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Quote Originally Posted by wqweto View Post
    IMO the query string should not be escaped/decoded. My observations are that WinHttp converts query strings to utf-8 and encodes every byte with highest bit set using %XY in hex to be able to "smuggle" headers through 7-bit networks probably (no idea actually).
    Perhaps I've misunderstood - but I think we have to be prepared to decode the query string (and the rest of the URL) server-side, because most browsers will encode the path/query portion of the URL. For example, this (insane) URL entered into the address bar (in Firefox):

    Code:
    http://127.0.0.1:8080/"test"?x=ABC DEF+"12345"
    Gets sent to the server encoded:

    Code:
    GET /%22test%22?x=ABC%20DEF+%2212345%22 HTTP/1.1
    Are you suggesting the the server should decode it, but the application on the server-side should if it wants to?

    Quote Originally Posted by wqweto View Post
    I think URLs are a big mess already,
    Ain't that the truth

    Quote Originally Posted by wqweto View Post
    probably would be best to make possible to submit to the http server *any* Unicode string in the query string with high fidelity i.e. convert to utf-8 and don't massage/process it too much.
    Sounds like the new URLRaw property will do that, and allow the server-side app to deal with URLs (exactly as passed) however they see fit.

  2. #82
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    151

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    Here's a very simple example that will evaluate formulas entered into your browsers address bar at the "evaluate/" path.
    Andt how do it not through a query string, but through a simple html (or, VBML) page, as if the user is entering text?
    so the plan is:
    1. 1) the user follows the link /calculator
    2. 2) enters an expression in the text box
    3. 3) presses the button and the request goes to the our server
    4. 4) the server returns the result of the expression to this page



    for example like here
    Name:  asp.net-simplate-calcula-2.png
Views: 173
Size:  6.6 KB

    Purely for understanding how the user interacts with the page and the server processes the received requests.
    Ten Years After - 01 You Give Me Loving

  3. #83

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Can you post the HTML source for that page? I will show you what to put on the server side.
    Last edited by jpbro; Jan 14th, 2022 at 10:43 AM.

  4. #84
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Posts
    3,596

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    Code:
    http://127.0.0.1:8080/"test"?x=ABC DEF+"12345"
    Gets sent to the server encoded:

    Code:
    GET /%22test%22?x=ABC%20DEF+%2212345%22 HTTP/1.1
    The point is that the same URL using WinHttpRequest sends this to server

    Code:
    GET /%22test%22?x=ABC%20DEF+"12345" HTTP/1.1
    . . . and the query string is somewhat *less* encoded than what chome does.

    Probably both requests use valid URL encodings because a simple %XY decoder would not be bothered if both spaces and double-quotes are encoded and decode the same query string anyway.

    Technically only % character has to be additionally escaped for a simple %XY decoder to produce valid query string. This query string should probably be treated as utf-8 encoded too.

    cheers,
    </wqw>

  5. #85

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    OK gotcha @wqweto.

  6. #86

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    I've just updated the first post with a new version that includes my first pass at a CBuilderHtml class. This is a helper class that makes it a bit quicker/easier to build HTML documents and HTML snippets for serving from your web apps.

    Here's a snippet from the demo app that builds and serves HTML when the browser requests the /virtualdoc/ path (e.g. http://127.0.0.1:8080/virtualdoc)

    Code:
          ElseIf po_Helpers.Regex.Test(po_Req.Url(urlsection_Path), "^virtualdoc(|/)$", False) Then
             ' Found a request for a "virtual" document
             ' We will build using the CBuilderHtml helper.
             New_C.Timing True
             
             With po_Helpers.Builders.Html.StartDoc ' Start an HTML5 document with the default parameters.
                ' Now in <head> section
                .AddTag "link", .BuildAttributes("rel", "stylesheet", "href", "https://cdn.simplecss.org/simple.min.css")
             End With   ' <head> section closes when it goes out of scope
             
             With po_Helpers.Builders.Html.AddTag("body")
                ' Now in the <body> section
    
                .AddTag "h1", , "Welcome!" ' Test of a tag with content (3rd parameter)
                
                With .AddTag("div", .BuildAttributes("id", "content"))   ' Test of tag with attributes (2nd parameter)
                   ' Test of build a paragraph with content and inline tags (the long way)
                   With .AddTag("p", , "This is a test of ")
                      .AddTag "b", , "VBWebAppServer.CBuilderHtml"
                      .AddContent "."
                   End With ' When CHtmlTag object goes out of scope, it automatically adds the closing </p> tag to the generate HTML
                   
                   .AddTag "hr"   ' Test of a self-closing tag. It will automatically be added to the generated HTML and no CHtmlTag will be returned
                
                   With .AddTag("p", , "Visit the ")
                      ' Link test
                      .AddTag "a", _
                             .BuildAttributes("href", "https://www.vbforums.com/showthread.php?893990-VB6-Web-Site-App-Server"), _
                             "VBWebAppFCGI thread at VBForums"
                      .AddContent "."
                   End With
                   
                   ' Test of simplified inline markdown content (faster way to build paragraph content with simple bold/italic/strike/superscript formatting
                   .AddTag "p", , "You can also add content with //simplified// inline markdown by passing **convert_InlineMarkdown** as the 2^^nd^^ parameter " & _
                                  "of the ~~AddsContents~~ ``AddContent`` method. Test of escaping\**. [[You can even create links with markdown^^]]((https://www.vbforums.com)), " & _
                                  "**so give the link a visit**!", contenttransform_InlineMarkdown
                   
                   ' Test of adding raw HTML content
                   .AddContent vbNewLine & "<p>You can even add raw HTML. Just make sure you escape it yourself if necessary and pass <i>contenttransform_None</i> to the second parameter of the <code>AddContent</code> method</p>", contenttransform_None
                   
                   ' Report how long it took to build the page
                   .AddTag "p", , "This page was generated in " & New_C.Timing
                End With
             End With
             
             ' Return the formula and the result as plain text.
             po_Response.SendSimpleHtmlResponse po_Helpers.Builders.Html.HtmlString
    The above generates the following HTML:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>New Page</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    <h1>Welcome!</h1>
    <div id="content">
    <p>This is a test of <b>VBWebAppServer.CBuilderHtml</b>.</p>
    <hr>
    <p>Visit the <a href="https://www.vbforums.com/showthread.php?893990-VB6-Web-Site-App-Server">VBWebAppFCGI thread at VBForums</a>.</p>
    <p>You can also add content with <i>simplified</i> inline markdown by passing <b>convert_InlineMarkdown</b> as the 2<sup>nd</sup> parameter of the <strike>AddsContents</strike> <code>AddContent</code> method. Test of escaping**. <a href="https://www.vbforums.com">You can even create links with markdown^^</a>, <b>so give the link a visit</b>!</p>
    <p>You can even add raw HTML. Just make sure you escape it yourself if necessary and pass <i>contenttransform_None</i> to the second parameter of the <code>AddContent</code> method</p><p>This page was generated in  0.67msec</p>
    </div>
    </body>
    </html>
    Which looks like this in the browser:

    Name:  CBuilderHtmlExample.jpg
Views: 165
Size:  31.7 KB

    PLEASE NOTE: This is very new code, and is very lightly tested. Bugs are all but guaranteed. Please let me know if you find any and I will fix them. Also, the programming interface may change significantly as I use it more and discover shortcomings, so don't make anything serious that relies on this new feature (or any part of VBWebAppServer for that manner) yet!

    Notes on VBWebAppServer's Simplified Inline Markdown

    I'm using my own flavour of "markdown" (I know, I know - just what the world needs). It has just a few tags chosen to make it easier to do inline formatting of text content in HTML documents. For example, if you want bold or italic spans in a paragraph. This feature has also been lightly tested, so beware of bugs.

    Consider this markdown string:

    Code:
    "You can also add content with //simplified// inline markdown by passing **convert_InlineMarkdown** as the 2^^nd^^ parameter of the ~~AddsContents~~ ``AddContent`` method. Test of escaping\**. [[You can even create links with markdown^^]]((https://www.vbforums.com)), **so give the link a visit**!"
    It will be transformed to the following HTML:

    Code:
    You can also add content with <i>simplified</i> inline markdown by passing <b>convert_InlineMarkdown</b> as the 2<sup>nd</sup> parameter of the <strike>AddsContents</strike> <code>AddContent</code> method. Test of escaping**. <a href="https://www.vbforums.com">You can even create links with markdown^^</a>, <b>so give the link a visit</b>!
    Here are the markdown tags and their respective HTML translations:

    Code:
       ** -> Bold, e.g. <b></b>
       // -> Italic, e.g. <i></i>
       __ -> Underline, e.g. <u></u>
       ^^ -> Superscript, e.g. <sup></sup>
       ~~ -> Strikethrough, e.g. <strike></strike>
       `` -> Code, e.g. <code></code>
       [[LinkText]]((LinkTarget)) -> Hyperlink. e.g. <a href="LinkTarget">LinkText</a>
    Enjoy!
    Last edited by jpbro; Jan 14th, 2022 at 09:55 PM.

  7. #87

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Updated the source in post one, and made some small changes to the CBuilderHtml demo code to show how you can add stuff to the <head> section. Also added some more comments to make it easier to understand what's happening when building an HTML page with the CBuilderHtml class.

  8. #88

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Sorry folks, I managed to muck up the last update. It's fixed now in the latest post, so if you had any trouble with yesterday's update, the latest version should be fine.

  9. #89

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Another fun update, demonstrating how you might dynamically generate a QR code JPEG and serve it to the browser.

    In the demo app, you can navigate to http://127.0.0.1:8080/qrencode/texttoencode, and a QR code image will appear in your browser. For example, here's what you see if you navigate to http://127.0.0.1:8080/qrencode/https://www.vbforums.com:

    Name:  qrcode.jpg
Views: 152
Size:  19.7 KB

    This is generated using the following code in the demo CApp class:

    Code:
             ElseIf po_Helpers.Regex.Test(po_Req.Url(urlsection_Path), "^qrencode/", False) Then
                ' Generate a QR Code image and send it back to the client as a JPEG
             
                Dim l_QrData As String
                Dim lo_QrEncode As cQREncode
                Dim lo_QrImage As cCairoSurface
                Dim la_QrImage() As Byte
                Dim l_QrWidth As Long
                Dim l_QrHeight As Long
                
                ' The portion of the requested path after "qrencode/" is the text that the client wants to encode
                l_QrData = Mid$(po_Req.Url(urlsection_Path), Len("qrcode/") + 1)
                
                Set lo_QrEncode = librc6QrEncode
                If lo_QrEncode Is Nothing Then
                   ' Uhoh! RC6Widgets.dll not found!
                   po_Response.SendSimplePlainTextResponse "To use the QR code feature, you must first copy RC6Widgets.dll to " & pathSystem, , 500
                   
                Else
                   ' Encode the passed text to a QR Code image surface
                   Set lo_QrImage = lo_QrEncode.QREncode(StrConv(l_QrData, vbFromUnicode), , , 10)
                   
                   ' Add a white border around the QR code
                   With lo_QrImage
                      l_QrWidth = .Width + 20
                      l_QrHeight = .Height + 20
                   End With
                   Set lo_QrImage = lo_QrImage.CropSurface(-10, -10, l_QrWidth, l_QrHeight)
                   With lo_QrImage.CreateContext
                      .Rectangle 0, 0, l_QrWidth, l_QrHeight
                      .Rectangle 10, 10, l_QrWidth - 20, l_QrHeight - 20
                      .SetSourceColor vbWhite
                      .FillRule = CAIRO_FILL_RULE_EVEN_ODD
                      .Fill
                   End With
                                  
                   ' Send the QR Code JPEG to the browser
                   lo_QrImage.WriteContentToJpgByteArray la_QrImage
                   po_Response.SendSimpleByteArrayResponse la_QrImage, , , "image/jpeg"
                End If
    Enjoy!

  10. #90
    Hyperactive Member
    Join Date
    Jun 2016
    Location
    EspaСЃa
    Posts
    312

    Re: VB6 Web Site/App Server

    good job, work perfect

  11. #91
    Lively Member
    Join Date
    Aug 2017
    Posts
    75

    Re: VB6 Web Site/App Server

    Good project, but would it be possible to do without RC6?

  12. #92
    Lively Member
    Join Date
    Nov 2017
    Location
    South Australia ( SA )
    Posts
    106

    Re: VB6 Web Site/App Server

    G'Day GB

    Quote Originally Posted by germano.barbosa View Post
    Good project
    100% agree

    Quote Originally Posted by germano.barbosa View Post
    would it be possible to do without RC6?
    Why don't you want to use RC6 ?

  13. #93

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Quote Originally Posted by germano.barbosa View Post
    Good project, but would it be possible to do without RC6?
    Thank you. Yes it would be possible, but a fair amount of work for little (if any) benefit IMHO. You would need to make the following replacements:

    • SQLite
      Use ADO and Jet instead (in many cases slower)

    • cArrayList
      Use the vanilla VB6 arrays (maybe better performing, but more painful for things like adding/removing elements)

    • cWebServer
      Roll your own using winsock API or Winsock control.

    • cWebResponse/cWebRequest
      Roll your own HTTP header and body parser, and WebSocket stuff (if you want to support WebSockets).

    • cSortedDictionary
      Use Scripting.Dictionary (slower)

    • cStringBuilder
      Roll your own or use one found in the codebank. Or just use vanilla VB6 string building (slower)

    • cCollection
      Use the vanilla VB6 Collection (slower, and without convenience methods like "Exists")

    • cFSO
      Use Scripting.FileSystemObject (slower)

    • cCrypt
      Roll your own/Use APIs for: URLEncode/URLDecode, SHA256, Cryptographic random number generation, String to UTF8 conversion.

    • Cairo
      Roll your own QR Encoding (or find something on the Internet). This one is optional, it was just for the demo app.


    There are somewhere around 200 lines of code that use RC6 in this project. At a 10x estimate, you would need to write about 2000 lines of code to replace RC6. That's a conservative estimate, I wouldn't be surprised if you need to write more.

    But the source is there if you want to fork it. I know some people don't want to use RC6, so they might appreciate your efforts!
    Last edited by jpbro; Jan 19th, 2022 at 01:44 PM.

  14. #94
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,039

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    Thank you. Yes it would be possible, but a fair amount of work for little (if any) benefit IMHO. You would need to make the following replacements:

    • SQLite
      Use ADO instead (in many cases slower)

    • cArrayList
      Use the vanilla VB6 arrays (maybe better performing, but more painful for things like adding/removing elements)

    • cWebServer
      Roll your own using winsock API or Winsock control.

    • cWebResponse/cWebRequest
      Roll your own HTTP header and body parser, and WebSocket stuff (if you want to support WebSockets).

    • cSortedDictionary
      Use Scripting.Dictionary (slower)

    • cStringBuilder
      Roll your own or use one found in the codebank. Or just use vanilla VB6 string building (slower)

    • cCollection
      Use the vanilla VB6 Collection (slower, and without convenience methods like "Exists")

    • cFSO
      Use Scripting.FileSystemObject (slower)

    • cCrypt
      Roll your own/Use APIs for: URLEncode/URLDecode, SHA256, Cryptographic random number generation, String to UTF8 conversion.

    • Cairo
      Roll your own QR Encoding (or find something on the Internet). This one is optional, it was just for the demo app.


    There are somewhere around 200 lines of code that use RC6 in this project. At a 10x estimate, you would need to write about 2000 lines of code to replace RC6. That's a conservative estimate, I wouldn't be surprised if you need to write more.

    But the source is there if you want to fork it. I know some people don't want to use RC6, so they might appreciate your efforts!
    That's a lot of work and you know I'm not a fan of re-inventing the wheel. I'd recommend that he doesn't try to re-create all this unless he wants to for the challenge of it but there is absolutely no value in reproducing sub-standard versions of something someone already created.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  15. #95
    Lively Member
    Join Date
    Aug 2017
    Posts
    75

    Re: VB6 Web Site/App Server

    The biggest problem for me is that RC6 is not opensource, I use it for other projects, but the least, if it was opensource I wouldn't worry

  16. #96
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,039

    Re: VB6 Web Site/App Server

    Yea, I get it. It's not future-proof while it's survival depends on a single individual. That may change one day perhaps.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  17. #97
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,875

    Re: VB6 Web Site/App Server

    If you use multiple commercial controls, which are not open source and are not maintained anymore.
    Are they future proof? As long as the OS and development platform supports them.
    Is open source future proof? No for same reasons.

    I really don't see the drive for having everything open source.

  18. #98
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,039

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Arnoutdv View Post
    If you use multiple commercial controls, which are not open source and are not maintained anymore.
    Are they future proof? As long as the OS and development platform supports them.
    Is open source future proof? No for same reasons.

    I really don't see the drive for having everything open source.
    Let me highlight the important part:-
    Yea, I get it. It's not future-proof while it's survival depends on a single individual. That may change one day perhaps.
    That changes everything. If Bill Gates kicks the bucket tomorrow, there will still be plenty of people at Microsoft who can make sure VB6 runs on Windows 13. God forbit it, but if Olaf shuffles off his mortal coil, then RC6 is just dead. Who will fix it when it crashes applications on Windows 13 or Windows 26?
    Last edited by Niya; Jan 21st, 2022 at 03:30 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  19. #99
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    4,875

    Re: VB6 Web Site/App Server

    And if a product is abandoned then the future is also not clear.
    See the multiple threads about commercial components which are not maintained/updated anymore.

    Especially for freeware, enjoy it as long as it works.
    If at some point it doesn't work anymore on a newer platform I think your "own" product will have more problems then just the single non open source component.

    Bet lets agree to disagree.

  20. #100
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    7,039

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Arnoutdv View Post
    And if a product is abandoned then the future is also not clear.
    See the multiple threads about commercial components which are not maintained/updated anymore.

    Especially for freeware, enjoy it as long as it works.
    If at some point it doesn't work anymore on a newer platform I think your "own" product will have more problems then just the single non open source component.

    Bet lets agree to disagree.
    I can still play the original Prince of Persia on DOSBox so I guess there's that possibility of unnatural longevity with zero developer input.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  21. #101
    Lively Member
    Join Date
    Aug 2017
    Posts
    75

    Re: VB6 Web Site/App Server

    Quote Originally Posted by Arnoutdv View Post
    If you use multiple commercial controls, which are not open source and are not maintained anymore.
    Are they future proof? As long as the OS and development platform supports them.
    Is open source future proof? No for same reasons.

    I really don't see the drive for having everything open source.
    I use 99% open source, not a third party control, only mine or available here on the forum

  22. #102
    PowerPoster
    Join Date
    Jun 2013
    Posts
    5,846

    Re: VB6 Web Site/App Server

    Quote Originally Posted by germano.barbosa View Post
    I use 99% open source...
    Well, that's only (mostly) true when you run your VB6-IDE on Linux+Wine -
    and when your customers run your App on Linux as well...

    If you develop on Windows (and your compiled App runs on Windows), then you're depending on about 90% closed source -
    (the OS-kernel, the OS-specific drivers, and all the libs in SysWow).

    Olaf

  23. #103
    Addicted Member sergeos's Avatar
    Join Date
    Apr 2009
    Location
    Belarus
    Posts
    151

    Re: VB6 Web Site/App Server

    Quote Originally Posted by jpbro View Post
    Can you post the HTML source for that page? I will show you what to put on the server side.
    sorry for late response
    this is my html example

    Code:
    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
    
        <title>Aligning Buttons</title>
    </head>
    
    <body>
        <h1 style="color:green;text-align:center;">NumberSender</h1>
        <div class="container">
            <div class="text-left">
                <button type="button">1</button>
                <button type="button">2</button>
                <button type="button">3</button>
                <button type="button">4</button>
                <button type="button">5</button>
                <button type="button">6</button>
            </div>
    
            <table width="500" border="1">
                <tr>
                    <th>ROW #</th>
                    <th>COLOR #</th>
                </tr>
                <tr>
                    <td>ROW 1</td>
                    <td bgcolor="red">COLOR 2</td>
                </tr>
                <tr>
                    <td>ROW 2</td>
                    <td bgcolor="green">COLOR 5</td>
                </tr>
            </table>
    </body>
    <div>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js">
        </script>
        </body>
    
    </html>
    what scenario I'm need:
    1) user click any button on the page
    2) server receive this number of the button and insert row into table with color
    3) user see updated page
    Ten Years After - 01 You Give Me Loving

  24. #104

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    Regarding the open/closed source thing, all I'll say is that RC6 (and earlier incarnations) is always the first reference I add to any new project I create. It makes me so much more productive that I am willing to take the risk of Olaf disappearing one day. It's not like it will just suddenly break either, but perhaps eventually an OS update will break it. I suspect that would also mean that VB6 apps will no longer work either, which would mean we even bigger problems to solve.

    Anyway, if you don't like the thought of using a closed-source library, that's totally your choice. Like I said, this project is open source and you are more than welcome to fork it if you think there's value in a version without the extra dependency.

  25. #105

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,013

    Re: VB6 Web Site/App Server

    @sergeos

    I've modified your HTML a bit to use Jquery for AJAX and modifying the DOM. I'm just familiar with it, so it was easier for me to create the demo. Feel free to substitute your favourite framework or just use vanilla JS if you prefer.

    To start, save the following HTML to you web app root folder as "tableaddtest.html":

    Code:
    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" />
    
        <title>Aligning Buttons</title>
    </head>
    
    <body>
        <h1 style="color:green;text-align:center;">NumberSender</h1>
        <div class="container">
            <div id='buttons' class="text-left">
                <button type="button">1</button>
                <button type="button">2</button>
                <button type="button">3</button>
                <button type="button">4</button>
                <button type="button">5</button>
                <button type="button">6</button>
            </div>
    
            <table id='mytable' width="500" border="1">
                <tr>
                    <th>ROW #</th>
                    <th>COLOR #</th>
                </tr>
                <tr>
                    <td>ROW 1</td>
                    <td bgcolor="red">COLOR 2</td>
                </tr>
                <tr>
                    <td>ROW 2</td>
                    <td bgcolor="green">COLOR 5</td>
                </tr>
            </table>
        </div>
    
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
        <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
        <script>
            // Hook each # button's click event.
            $('#buttons button').click(function() { 
                // # button clicked
                var number = $(this).text();
            
                // Send AJAX query to the server at /numberreceiver/<number>
                $.ajax({
                    url: "/numberreceiver/" + number,
                })
                .done(function( json ) {
                    // Add a row to the table using the JSON response from the server
                    json = $.parseJSON(json);
                    var markup = "<tr><td>ROW " + ($('#mytable tr').length) + "</td><td bgcolor=" + json.bgcolor + ">COLOR " + number + "</td><</tr>";
            
                    $("#mytable").append(markup);
            
                    if ( json.status != 200 ) { alert('Error #' + json.status + ': ' + json.errormessage); }
                });			
            });
        </script>
    </body>
    
    </html>
    Then add the following code to the CApp class (somewhere after the If po_Helpers.Regex.Test(po_Req.Url(urlsection_Path), "^showcase/[0-9]+$", False) Then showcase code section:

    Code:
          ElseIf po_Helpers.Regex.Test(po_Req.Url(urlsection_Path), "^numberreceiver/[0-9]+$", False) Then
             ' Build JSON response
             ' JSON helper methods are forthcoming,
             ' but for now we'll have to use the ComplexResponse and manually add an "Content-Type: application/json" header
             With po_Response.ComplexResponse
                .AddHeaderEntry "Content-Type", "application/json"
                
                Set lo_Json = New_C.JSONObject
                With lo_Json
                   .Prop("status") = 200
                   
                   ' Get the color index # from the end of the URL path
                   .Prop("number") = Split(po_Req.Url(urlsection_Path), "/")(1)
                   
                   Select Case .Prop("number")
                   Case 1
                      .Prop("bgcolor") = "purple"
                   Case 2
                      .Prop("bgcolor") = "red"
                   Case 3
                      .Prop("bgcolor") = "blue"
                   Case 4
                      .Prop("bgcolor") = "yellow"
                   Case 5
                      .Prop("bgcolor") = "green"
                   
                   Case Else
                      ' Uhoh! Unknown color index
                      .Prop("status") = 500
                      .Prop("errormessage") = "Unknown color index #" & .Prop("number")
                      .Prop("bgcolor") = "gray"
                   End Select
                End With
                .SetResponseDataBytes lo_Json.SerializeToJSONUTF8
             End With
    Finally, start the app server and navigate to http://127.0.0.1:8080/tableaddtest.html and try clicking some buttons. You should see something like this:

    Name:  numbersender.jpg
Views: 26
Size:  18.0 KB

    Until you click #6, then you will see a simulated error:

    Name:  numbersendererr.jpg
Views: 26
Size:  8.8 KB

    I hope the code and comments are enough to demonstrate how this type of thing can be done, but let me know if you have any questions.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width