Web Servers

“Hard-Coded” Dynamic Server

Generalized Dynamic Server (CGI)

Passing “parameters”

Writing programs that generate HTML.

name = "bob"

doc_string = f"""
   <html>
     <head>
        <title>My Dynamic Web Page</title>
     </head>
     <body>
     <h1>Welcome</h1>
        Hello, {name}!
     </body>
   </html>"""
   
print(doc_string)
use POSIX;

my $time = strftime "%H:%M", localtime time;

print <<HERE
<html>
<body>
<h2> Hello, World!</h2>

<p>At the tone time time (at the server) will be $time.</p>

(from perl)
</body>
</html>
HERE

Frameworks

Imagine you are designing a system to create dynamic web pages. What types of features are you looking for? * A library of functions to do common tasks (so you don’t have to re-invent the wheel) * You might want to have your system just automatically call these functions for you saving even more time. * Frameworks are the result of these attempts to automate as much as possible allowing users to implement a web page with as little coding as reasonable. * When designing a framework, there is a fundamental tension between configuration and convention. * What things should be explicitly spelled out? * What things should just happen by “magic” if the code is written using certain names/patterns? * There is no right answer, which is why there is a long list of frameworks. * However, frameworks tend to follow similar patterns and have a number of things in common. * So, the goal here is not to make you an expert using any particular framework, but to highlight common patterns/techniques so that when you go to learn a specific framework, it doesn’t seem completely foreign and you have a mental model you can leverage.