I'm a doctor, not a mechanic

Legacy:HelloWeb

From Unreal Wiki, The Unreal Engine Documentation Site

Jump to: navigation, search
UT :: Object (UT) >> WebApplication >> HelloWeb (Package: UWeb)
UT2003 :: Object >> WebApplication >> HelloWeb (Package: UWeb)

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".

[edit] HelloWeb code

  1. class HelloWeb extends WebApplication;
    
  2.  
    
  3. /* Usage:
    
  4. This is a sample web application, to demonstrate how to program for the web server.
    
  5.  
    
  6. [UWeb.WebServer]
    
  7. Applications[0]="UWeb.HelloWeb"
    
  8. ApplicationPaths[0]="/hello"
    
  9. bEnabled=True
    
  10.  
    
  11. http://server.ip.address/hello
    
  12. */
    
  13.  
    
  14. event Query(WebRequest Request, WebResponse Response)
    
  15. {
    
  16. 	local int i;
    
  17.  
    
  18. 	if(Request.Username != "test" || Request.Password != "test")
    
  19. 	{
    
  20. 		Response.FailAuthentication("HelloWeb");
    
  21. 		return;
    
  22. 	}		
    
  23.  
    
  24. 	switch(Request.URI)
    
  25. 	{
    
  26. 	case "/form.html":
    
  27. 		Response.SendText("<form method=post action=submit.html>");
    
  28. 		Response.SendText("<input type=edit name=TestEdit>");
    
  29. 		Response.SendText("<p><select multiple name=selecter>");
    
  30. 		Response.SendText("<option value=\"one\">Number One");
    
  31. 		Response.SendText("<option value=\"two\">Number Two");
    
  32. 		Response.SendText("<option value=\"three\">Number Three");
    
  33. 		Response.SendText("<option value=\"four\">Number Four");
    
  34. 		Response.SendText("</select><p>");
    
  35. 		Response.SendText("<input type=submit name=Submit value=Submit>");
    
  36. 		Response.SendText("</form>");
    
  37. 		break;
    
  38. 	case "/submit.html":
    
  39. 		Response.SendText("Thanks for submitting the form.<br />");
    
  40. 		Response.SendText("TestEdit was \""$Request.GetVariable("TestEdit")$"\"<p>");
    
  41. 		Response.SendText("You selected these items:<br>");
    
  42. 		for(i=Request.GetVariableCount("selecter")-1;i>=0;i--)
    
  43. 			Response.SendText("\""$Request.GetVariableNumber("selecter", i)$"\"<br>");
    
  44. 		break;
    
  45. 	case "/include.html":
    
  46. 		Response.Subst("variable1", "This is variable 1");
    
  47. 		Response.Subst("variable2", "This is variable 2");
    
  48. 		Response.Subst("variable3", "This is variable 3");
    
  49. 		Response.IncludeUHTM("testinclude.html");
    
  50. 		break;
    
  51. 	default:		
    
  52. 		Response.SendText("Hello web!  The current level is "$Level.Title);
    
  53. 		Response.SendText("<br>Click <a href=\"form.html\">this link</a> to go to a test form");
    
  54. 		break;
    
  55. 	}
    
  56. }
    
Personal tools