Difference between revisions of "TutWebAppServer Lesson 1 - Hello World"
Jump to navigation
Jump to search
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
During this lesson, you will learn how to write the simplest website. The website you'll build has only one static page displaying "Hello World". | During this lesson, you will learn how to write the simplest website. The website you'll build has only one static page displaying "Hello World". | ||
− | + | == Steps == | |
<ol> | <ol> | ||
<li> Create a new VCL forms application. | <li> Create a new VCL forms application. | ||
Line 37: | Line 35: | ||
</ol> | </ol> | ||
<br> | <br> | ||
− | + | == Summary == | |
In this lesson you learned how to build the basic webserver to serve static page. Beside the static pages you need, there are only two Delphi code lines to write. | In this lesson you learned how to build the basic webserver to serve static page. Beside the static pages you need, there are only two Delphi code lines to write. | ||
<br><br> | <br><br> | ||
− | Next lesson: [[TutWebAppServer Lesson 2 - Hello Today|Hello Today]] | + | Next lesson: [[TutWebAppServer Lesson 2 - Hello Today|Hello Today]]<br> |
+ | Tutorial presentation: [[TutWebAppServer]] |
Latest revision as of 18:29, 4 May 2009
During this lesson, you will learn how to write the simplest website. The website you'll build has only one static page displaying "Hello World".
Steps
- Create a new VCL forms application.
- Here in the demo we use a classic GUI application. For a real application, it is likely that you'll create a service application.
- Rename the form "TutWebAppServerMainForm"
- On the form just created, drop a THttpAppSrv component.
- Save the files you have just created. Menu / File / Save all. Use OverbyteIcsTutWebAppServerMain.pas instead of unit1.pas and OverbyteIcsTutWebAppServer.dproj instead of project1.dproj.
- Hit F9 to compile and run the projet. You should get no error and a blank form. If you have errors, then it is likely you have ICS incorrectly installed. Terminate the application.
- Select the THttpAppSrv you just dropped on a form. Hit F11 to show the oject inspector and set a few property values:
Name HttpAppSrv1 Port 20080 DocDir c:\icstutorial\wwwroot TemplateDir c:\icstutorial\templates DefaultDoc index.html
- Create the document directory "c:\icstutorial\wwwroot" and the templates directory "c:\icstutorial\templates".
- Create our static html page: Menu / File / New / Others / Web document / HTML Page. Just enter the body text "Hello World" and save the file as "c:\icstutorial\wwwroot\index.html"
- Add a FormShow event handler to TutWebAppServerMainForm with the code:
- HttpAppSrv1.AddGetAllowedPath('/', afBeginBy);
- HttpAppSrv1.Start;
- Hit CTRL-SHIFT-S to save all.
- Hit F9 to compile and run the application. You still get an empty form, but actually you already have a web server running ! Depending on your OS and security settings, you may get a message asking you to block or allow the application. Be sure to allow it.
- Now enter the url: "http://127.0.0.1:20080" into your favorite browser. You should get your marvelous "Hello World" static page.
Summary
In this lesson you learned how to build the basic webserver to serve static page. Beside the static pages you need, there are only two Delphi code lines to write.
Next lesson: Hello Today
Tutorial presentation: TutWebAppServer