Lecture 2 Revision

Creating and Deploying Web Applications

HTML recap

<html>
<head>
  <title>Sample HTML Page Structure</title>
</head>
<body>

  <h1>Heading 1</h1>

  <p><b>Welcome</b> to <i>HTML</i>!</p>

</body>
</html>

HTML Tables:

<!DOCTYPE html>
<html>
<head>
  <title>Table of Harry Potter Books:</title>
</head>
<body>
  <h2>Table of Harry Potter Books:</h2>
  <table border="1">
    <thead>
      <tr>
        <th>Title</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>Harry Potter and the Philosopher's Stone</td>
        <td>Harry discovers he is a wizard and attends Hogwarts for the first time.</td>
      </tr>
      <tr>
        <td>Harry Potter and the Chamber of Secrets</td>
        <td>Harry returns to Hogwarts and investigates a series of mysterious petrifications.</td>
      </tr>
      <tr>
        <td>Harry Potter and the Prisoner of Azkaban</td>
        <td>Harry learns about his family's past and encounters a dangerous escaped prisoner.</td>
      </tr>
    </tbody>
  </table>
</body>
</html>

the table from above

Title Description
Harry Potter and the Philosopher's Stone Harry discovers he is a wizard and attends Hogwarts for the first time.
Harry Potter and the Chamber of Secrets Harry returns to Hogwarts and investigates a series of mysterious petrifications.
Harry Potter and the Prisoner of Azkaban Harry learns about his family's past and encounters a dangerous escaped prisoner.

Cascading Style Sheets (CSS) - why cascading?

Forms

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Blog Post Form:</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <h1>Write a Blog Post</h1>
  <form action="/submit-blog" method="post">
    <div>
      <label for="title">Title:</label>
      <input type="text" id="title" name="title" required>
    </div>
    <div>
      <label for="blog">Blog Content:</label>
      <textarea id="blog" name="blog" rows="10" cols="50" required></textarea>
    </div>
    <div>
      <button type="submit">Submit</button>
    </div>
  </form>
</body>
</html>

In html:


Write a Blog Post


Form - method Get vs Post

GET Method

POST Method

alt text

PHP – Forms – Get vs Post

alt text

When to use Get

UQCloud and NGINX Web Server

The basic elements of a web server includes

alt text

Operating system

A operating system is what allows you to interact with the applications and hardware that make up your computer. It facilitates resource allocation to your applications, and communication between hardware and software. Typically, operating systems for servers fall under three categories:

Top five open source web server

Connecting to your student zone

SSH

SFTP

NGINX Web server – Basic config file

http {
    server {
        listen 80; # Listen on port 80 for HTTP requests
        server_name example.com; # Replace with your domain name or use localhost

        # Document root where the files are located
        root /var/www/html/htdocs;

        # Default file to serve
        index index.html index.htm;

        # Serve files
        location / {
            try_files $uri $uri/ =404;
        }
    }
}
location / {
    try_files $uri $uri/ =404;
}

After you change the configuration run:

$ sudo systemctl reload nginx

HTTP Status Codes

HTTP status codes are standardized responses that a web server sends to your browser to indicate the outcome of a requested action.

Code Description
200 Ok The request has succeeded. The meaning of the success depends on the HTTP method used.
201 Created The request has been fulfilled, resulting in the creation of a new resource.
400 Bad Request The server cannot process the request due to a client error (e.g., malformed request syntax).
401 Unauthorized The request requires user authentication.
404 Not Found The server has not found anything matching the Request-URI.
408 Request Timeout The client did not produce a request within the time that the server was prepared to wait.
500 Internal Server Error The server encountered an unexpected condition which prevented it from fulfilling the request. Usually a server-side setup issue or server-side coding error.