Tutorial 1: Building a TurboHtml server using Indy.This tutorial shows how to build a TurboHtml web application using Indy's HTTP Server component (TIdHttpServer). There are five steps in this tutorial.
|
|
| |
|
| 1. Create a server. | |
Create a new standard application. Add a TidHttpServer to the main form. Set the Active property to true.
|
|
| |
|
| 2. Connect a TurboHtml WebApp component. | |
Add a TTrbWebApp component (from the TrbWeb tab on the component palette). Add a TTrbIndyBridge component. Set the HttpServer property of the TrbIndyBridge1 to IdHttpServer1. Set the WebApp property to TrbWebApp1.
|
|
| |
|
| 3. Create a page form. | |
Add a blank form to the project. We will call this form a page form because it will be displayed as a web page in the browser. Add a TTrbWebForm component (from the TrboHtml tab on the component palette). Add TurboHtml controls. Make sure
your page form is not auto-created. |
For this example, we added a TTrbLabel, set the Caption to "Hello World" and set the TrbWebForm1.PageFont to Arial 24. |
| |
|
| 4. Connect the page to the server. | |
On the main form, select TrbWebApp1, and activate
the collection editor for the Pages property. Add a new page
item. |
|
| Select the new TTrbAppPagesItem and switch to the Events tab of the inspector. Double-click the OnRequestFormClass event. Add code to the event as shown below. TPage1Form should correspond to the class of the form you created in Step 3.
|
|
![]() |
|
Add the unit for the page form to the implementation uses clause of the web module. The File|Use Unit... (Alt-F11) menu item can make this easier.
|
|
| |
|
| 5. Run the application and request the page from a browser. | |
Compile and run the application. The server window appears. Open a browser, and request the page: http://localhost
For our test application, DefaultPort was 90, so in the figure below the URL is: http://localhost:90 |
![]() |
|
|
|