HelloWeb
This is a sample web application, to demonstrate how to program for the web server.
To use it open UnrealTournament.ini, search the [UWeb.WebServer] section and add
Applications[x]="UWeb.HelloWeb" ApplicationPaths[x]="/hello" bEnabled=True
(Change "x" to the first unused slot, usually 2.)
Then start a dedicated UT server and open a web browser. Type http://server-ip/hello as address and play around with the pages. The user name and password are both "test".
HelloWeb code
00001 class HelloWeb extends WebApplication; 00002 00003 /* Usage: 00004 This is a sample web application, to demonstrate how to program for the web server. 00005 00006 [UWeb.WebServer] 00007 Applications[0]="UWeb.HelloWeb" 00008 ApplicationPaths[0]="/hello" 00009 bEnabled=True 00010 00011 http://server.ip.address/hello 00012 */ 00013 00014 event Query(WebRequest Request, WebResponse Response) 00015 { 00016 local int i; 00017 00018 if(Request.Username != "test" || Request.Password != "test") 00019 { 00020 Response.FailAuthentication("HelloWeb"); 00021 return; 00022 } 00023 00024 switch(Request.URI) 00025 { 00026 case "/form.html": 00027 Response.SendText("<form method=post action=submit.html>"); 00028 Response.SendText("<input type=edit name=TestEdit>"); 00029 Response.SendText("<p><select multiple name=selecter>"); 00030 Response.SendText("<option value=\"one\">Number One"); 00031 Response.SendText("<option value=\"two\">Number Two"); 00032 Response.SendText("<option value=\"three\">Number Three"); 00033 Response.SendText("<option value=\"four\">Number Four"); 00034 Response.SendText("</select><p>"); 00035 Response.SendText("<input type=submit name=Submit value=Submit>"); 00036 Response.SendText("</form>"); 00037 break; 00038 case "/submit.html": 00039 Response.SendText("Thanks for submitting the form.<br>"); 00040 Response.SendText("TestEdit was \""$Request.GetVariable("TestEdit")$"\"<p>"); 00041 Response.SendText("You selected these items:<br>"); 00042 for(i=Request.GetVariableCount("selecter")-1;i>=0;i--) 00043 Response.SendText("\""$Request.GetVariableNumber("selecter", i)$"\"<br>"); 00044 break; 00045 case "/include.html": 00046 Response.Subst("variable1", "This is variable 1"); 00047 Response.Subst("variable2", "This is variable 2"); 00048 Response.Subst("variable3", "This is variable 3"); 00049 Response.IncludeUHTM("testinclude.html"); 00050 break; 00051 default: 00052 Response.SendText("Hello web! The current level is "$Level.Title); 00053 Response.SendText("<br>Click <a href=\"form.html\">this link</a> to go to a test form"); 00054 break; 00055 } 00056 }