External Exam Download Resources Web Applications Games Recycle Bin

Basic Algorithm for a Web Server

A "main" algorithm for a web server could look something like this:

BEGIN
  WHILE True

    INPUT url

    IF url == "/home" THEN
      RETURN home.html
    ENDIF

    IF url == "/login" THEN
      RETURN login.html
    ENDIF

  ENDWHILE
END

A simulation of this is as follows:

while True:
  
  url = input("url: ")

  if "home" in url:
    print("home.html")

  if "login" in url:
    print("login.html")