Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 7: Static Website Hosting (3 OSes × 2 Web Servers)

AWS Cloud

7.3 Step 1 (common): create the sample website

Now open your terminal and try this with me. Run this in your local training shell or an approved disposable guest. It creates a fresh ~/mysite with an index.html, CSS and an error-document candidate. If that folder already exists, use the unique scratch setup below instead.

(
set -eu
mkdir "$HOME/mysite" || {
  printf '%s\n' 'Cannot create a new ~/mysite. Use the unique scratch setup below.' >&2
  exit 1
}
mkdir "$HOME/mysite/css"
cat > ~/mysite/index.html <<'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My First Cloud Website</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <header><h1>Namaste from AWS EC2!</h1></header>
  <main>
    <p>This sample website is ready to preview or publish in an approved training environment.</p>
    <ul>
      <li>Cloud: Amazon Web Services</li>
      <li>Hosting exercise: use your approved environment</li>
      <li>Content: HTML + CSS</li>
    </ul>
  </main>
  <footer>Hosted as part of the AWS Hands-On Handbook lab</footer>
</body>
</html>
EOF
cat > ~/mysite/css/style.css <<'EOF'
body   { font-family: Arial, sans-serif; margin: 0; background: #f4f7fb; color: #222; }
header { background: #0b3d6e; color: #fff; padding: 20px; text-align: center; }
main   { max-width: 700px; margin: 30px auto; background: #fff; padding: 20px; border-radius: 8px; }
footer { text-align: center; color: #777; padding: 20px; }
EOF
cat > ~/mysite/404.html <<'EOF'
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Page Not Found</title></head><body><main><h1>Page not found</h1><a href="index.html">Return to the practice home page</a></main></body></html>
EOF
ls -R "$HOME/mysite"
)

Ravindra Bagale's Tip

Many students write <<EOF (without quotes) instead of <<'EOF' in a heredoc – then the shell replaces words with $ and the file comes out wrong. Keep the quotes, and write the closing EOF at the start of the line with no spaces before or after.

Lab

Create only the new practice directory or the unique scratch directory below. Verify the expected files, edit the exact scratch home page title, and test both the content and the HTTP response. Keep any existing ~/mysite project untouched.

Build the files that will be published before you configure a server

Mauli Dairy wants a small information site with a home page, a daily rates page and a plain explanation for a missing route. Start by building that content in an authoring directory. Hosting is the later job of making selected finished files available under an approved URL. A candidate site is easier to verify when its file tree and browser behavior already make sense before you add a domain, permissions, a cloud route or a web-server package.

Choose one concrete structure. The home page is named index.html. The rate table lives at rates.html. The two pages share css/style.css. The file 404.html is an error-page body you can preview as a document. A server that uses it for errors still needs an explicit error-page configuration. The file's name by itself does not change the HTTP status or error body at a missing path. This exercise keeps page design and server configuration visibly separate.

Use a dedicated scratch directory with no existing website files. You can run the authoring commands on a local Unix-like shell, including a permitted Linux or macOS environment, and preview with Python 3. Windows learners can use their approved Bash environment or write the same files in an editor. No Amazon EC2 launch, privilege elevation or public listener is needed for the local proof. Use the course's approved isolated host only if that is your assigned environment.

The example rates and text are fictional. Keep actual customer details, keys, work notes and archived material out of the directory you intend to publish. The person who prepares a web artifact controls which files a visitor can request. Build the publication tree from a short known list and check it before it goes anywhere. A private file is not protected simply because no home page link points to it.

Create a unique working directory that cannot overwrite another project

Open a Bash terminal. The setup command below asks mktemp to create a new private scratch directory with a unique name. A folder named with a fixed label could already contain an earlier lab or another project. Wiping or replacing that folder is unnecessary. A new directory gives this candidate a clean starting point and a known place to remove its test files later.

site_lab=$(mktemp -d "${TMPDIR:-/tmp}/mauli-site.XXXXXX") &&
  mkdir "$site_lab/css" &&
  printf 'New site directory: %s\n' "$site_lab"

Expected output starts with New site directory: and includes a unique local path. If you don't see that result, stop and check the local environment before writing the pages. Keep the exact value in this terminal for the remaining commands. Learners can leave the first shell open while using a second for HTTP checks. A shell variable belongs to its shell process; it does not appear magically in another independently opened window. You can use the printed path to identify the same scratch directory.

TMPDIR refers to the system's allowed temporary directory when provided, while the shell expansion uses /tmp when that variable is missing or empty. The website files are written under the path returned by mktemp. Quoting "$site_lab/css" treats the full path as one shell argument even if it contains spaces. The && operators only attempt each next command after the previous one succeeds. Those details reduce avoidable errors before the site files exist.

Keep only your own scratch content in the new directory. Files you want to bring to a later lesson need an authorized handoff location and a clear copy procedure. A temporary directory can be cleaned by the operating system or instructor and should not be the only copy of your real project. This exercise verifies a candidate publication and lets you choose separately where to keep the approved artifact.

Write a page with useful landmarks and a working navigation link

Create the home page first. Its structure uses a document declaration, language, character encoding and a viewport setting, then a title and stylesheet link. The heading identifies the site. The navigation contains meaningful labels, and the main section tells readers exactly which training data they can check. Semantic elements provide structure for browsers and assistive technology. A visually bold line alone is not an equivalent heading.

test -n "${site_lab:-}" && test -d "$site_lab/css" &&
  cat > "$site_lab/index.html" <<'HTML'
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Mauli Dairy Training Site</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <header>
    <p class="release">Training release one</p>
    <h1>Mauli Dairy</h1>
    <nav aria-label="Site">
      <a href="index.html" aria-current="page">Home</a>
      <a href="rates.html">Sample milk rates</a>
    </nav>
  </header>
  <main>
    <h2>Practice reading a published rate sheet</h2>
    <p>These practice prices are fictional. Open the rate sheet to see the sample products.</p>
  </main>
  <footer>Mauli Dairy static hosting exercise</footer>
</body>
</html>
HTML

The document title appears in the browser's tab or history. The h1 identifies the page to readers. The visible release line helps distinguish two versions during testing. The label “Sample milk rates” tells a reader where the link will take them. The example uses a relative path because both HTML files are in the same directory. You can publish this simple tree under a separate path prefix without changing those two sibling links, assuming the rest of the host configuration preserves that directory structure.

The declaration and language are part of the document. Character encoding matters when the file includes local-language text or a currency character. The viewport metadata gives mobile browsers information about the intended layout width. Still inspect the result on a small viewport. A page can have correct viewport metadata and a fixed-width table that overflows. Test the rendered page as well as the delivered file.

Make a small rule for edits. Change one heading or document label and inspect the existing file before saving. If an editor adds a hidden extension or saves a second copy, the server will continue using the named file it was configured to serve. Avoid editing inside a live server root for this beginner exercise. Verify the exact scratch path and intended release version before moving files to any shared area.

Add a second page that shares the same stylesheet

A rate list is structured data, so a table is suitable here. A caption explains the purpose. Column headers identify the product and example rate, and row headers label each product. Keep units in the visible headings or values so the reader does not need to guess whether a rate refers to one litre or a packet. Use fictional values throughout the exercise. A public page should also tell readers when it is a training artifact.

test -n "${site_lab:-}" && test -d "$site_lab/css" &&
  cat > "$site_lab/rates.html" <<'HTML'
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Sample Milk Rates | Mauli Dairy</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <header>
    <p class="release">Training release one</p>
    <h1>Sample milk rates</h1>
    <nav aria-label="Site">
      <a href="index.html">Home</a>
      <a href="rates.html" aria-current="page">Sample milk rates</a>
    </nav>
  </header>
  <main>
    <table>
      <caption>Practice values for this static release</caption>
      <thead><tr><th scope="col">Product</th><th scope="col">Example rate per litre</th></tr></thead>
      <tbody>
        <tr><th scope="row">Cow milk</th><td>₹52</td></tr>
        <tr><th scope="row">Buffalo milk</th><td>₹65</td></tr>
      </tbody>
    </table>
    <p>These values describe the training exercise only.</p>
  </main>
  <footer>Mauli Dairy static hosting exercise</footer>
</body>
</html>
HTML

Compare the two pages. Both request css/style.css relative to their location. Both use a meaningful primary heading and navigation. The current-page text is labelled as current on the corresponding link. The copy of the stylesheet remains in one place, so each page can use it. If one HTML file moves into a subdirectory, its relative asset text may point somewhere else. Recalculate the requested URL and test from the moved location rather than copying the same link without checking.

A rate change edits the intended value and associated version in this prepared file and follows the approval procedure. A multiple-language or data-generated application might build these files from another source. The useful artifact for the Web server is still the published representation. Check the actual contents your chosen build emits, and record the relation to the approved source values.

Understand how the shell writes literal text to a file

A here-document lets the shell pass several lines to a command. In these examples, cat reads the body and output redirection writes it to the selected file. The quoted delimiter in <<'HTML' tells the shell to keep the text literal under the documented shell rules. A currency label, a dollar sign in code or other expressions will remain in the body instead of being interpreted as shell variables or commands. The quotes affect the document body, while the separate path "$site_lab/index.html" still uses the intended variable expansion.

The closing HTML must be on a line by itself and exactly match the label. Avoid added spaces around it. If a terminal keeps showing a continuation prompt, check the delimiter and line boundaries. Cancelling an unexpectedly unfinished command returns you to the shell without guessing which further lines it would interpret. Use a text editor when that is more comfortable. The goal is to write specific file contents, not force one authoring method.

Output redirection using > can replace an existing file. That is why the visible commands target a unique scratch directory created for this exercise. Running the same block again will recreate that scratch file. If you intended to preserve an earlier set of edits, copy its approved version out before running a replacement. Do not point the variable at an existing site, backup or shared server directory just because its name is convenient. The option to use a fresh directory is part of the exercise's safety and reproducibility.

Practice interpreting the output. A successful cat redirection can produce no visible terminal content because its output went to the file. File existence is the next check. Display or open the exact expected local file, then inspect its text or preview response. If the file is absent or empty, check the shell operation and directory before investigating an HTTP server. Nothing has been published by a successful local redirection.

Apply styles for readable text, narrow screens and keyboard navigation

Use one CSS file for both pages. A browser that receives the stylesheet changes presentation without changing the document's semantic relationships. Set a readable base font and line spacing, make the layout adapt to its container, and keep anchor links visible. Choose a clear focus indicator so a keyboard user can see which element is active. CSS should support the information already present in the HTML.

test -n "${site_lab:-}" && test -d "$site_lab/css" &&
  cat > "$site_lab/css/style.css" <<'CSS'
body {
  margin: 0;
  color: #172331;
  background: #f2f6fb;
  font: 1rem/1.6 system-ui, sans-serif;
}

header, main, footer {
  box-sizing: border-box;
  width: min(100%, 46rem);
  margin-inline: auto;
  padding: 1.25rem;
}

header h1 { margin-block: 0.25rem; }
.release { color: #35516f; }

main {
  border: 1px solid #b7c7d8;
  background: #fff;
}

nav a { display: inline-block; margin-inline-end: 1rem; }
a { color: #104680; }
a:focus-visible { outline: 3px solid #7a3900; outline-offset: 3px; }

table { width: 100%; border-collapse: collapse; }
caption { text-align: start; font-weight: 700; }

th, td {
  border-bottom: 1px solid #c3d0dd;
  padding: 0.5rem;
  text-align: start;
}
CSS

The width uses the smaller of the available space and a maximum. The box sizing makes the main padding and border count within that width. A narrow page still deserves an actual test with a small sample viewport or a mobile browser. Ensure the table can fit or wrap sensibly, the links are reachable and focus visible, and text can be read. A browser default stylesheet or disabled style sheet should still leave understandable document structure.

A CSS file is its own requested resource. When the page appears with default styles, inspect the resource request URL, response status and content type before adjusting CSS selectors. If css/style.css returns HTML, the browser may refuse to use it even if the response status is 200. Check the exact file name and hosted location. If the file loads and the rule is not applied, inspect the selector and competing styles using the browser's developer tools in the authorized preview.

Prepare an error document and keep the intended HTTP status

An actual missing page needs a useful explanation and a way back. Create 404.html as a candidate file rather than a guess about server status. Its page explains that the requested document is missing and offers a meaningful navigation link. The same style keeps the example understandable. When you deploy a custom error page later, have the approved web server return the body while preserving the missing-resource status for the original request.

test -n "${site_lab:-}" && test -d "$site_lab/css" &&
  cat > "$site_lab/404.html" <<'HTML'
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Page Not Found | Mauli Dairy</title>
  <link rel="stylesheet" href="css/style.css">
</head>
<body>
  <main>
    <h1>Page not found</h1>
    <p>This training site could not find the requested page.</p>
    <p><a href="index.html">Return to Mauli Dairy home</a></p>
  </main>
</body>
</html>
HTML

A direct request for /404.html can return 200 because that file does exist. It is also the way to preview its text and style without a configured custom error handler. A request for a missing file should return 404 in the plain Python preview. The supplied file does not automatically become Python's error page. Apache and Nginx can apply different documented error-routing directives to control that behavior. The later hosting lesson verifies the actual status and body for a missing request, separately from an ordinary direct preview of the file.

There is another link detail to review before deploying an error page. If a server displays the error document without changing the URL, the browser may resolve its relative links from the original missing path. A missing nested URL could then make the style or home link point somewhere unintended. Choose an approved base-path-aware set of links for the configured error path and test a missing root-level and nested request. A leading slash works only when it refers to the intended domain-level publishing location. The example here is a document to inspect. Adjust its error links to the actual deployed scope.

Keep that design accessible. Write a readable document title, name the failure in the heading, and give a recovery link that makes sense without imagery or JavaScript. Check that an approved nonexistent route stays an error. An unrelated page can be a useful fallback for certain intentionally designed client routes, but a synthetic error test should not silently report success when the resource is absent.

Open an HTTP preview and check the pages, style and missing path

Use the same terminal where you created the scratch directory and run the loopback-only Python preview below. The example uses 8089 as a scratch port. If another process already owns it, do not stop that process. Pick a different approved unused port and use it consistently for the whole local exercise. Python's small server is for development checks on your own machine. It is not the operational server for a public production deployment.

test -n "${site_lab:-}" && test -f "$site_lab/index.html" &&
  python3 -m http.server 8089 --bind 127.0.0.1 --directory "$site_lab"

In a second local terminal use these checks while the preview runs. The paths point to this machine's loopback, not to a public instance. Each test prints headers and a safe response body from the example files. The missing request is intentionally allowed to show its HTTP error status. If a corporate environment restricts local processes or proxies, follow the approved local scope or fill in the expected outcomes on paper.

curl --noproxy '*' -i --max-time 5 http://127.0.0.1:8089/
curl --noproxy '*' -i --max-time 5 http://127.0.0.1:8089/rates.html
curl --noproxy '*' -i --max-time 5 http://127.0.0.1:8089/css/style.css
curl --noproxy '*' -i --max-time 5 http://127.0.0.1:8089/404.html
curl --noproxy '*' -i --max-time 5 http://127.0.0.1:8089/practice-missing.html

Expect 200 for the home page, rates, CSS and direct 404 document. The first two should contain the intended public page titles and correct release marker. The style response should use a CSS content type and include a known color or focus rule. The direct 404 page is HTML with a readable heading. The missing request should return 404 from Python and can use its built-in error body. Check status and useful content separately. If you receive a page belonging to another tool, verify the chosen port and process instead of changing its files.

Now open the permitted local preview in a browser, follow the rate link, and use the browser's Network panel to inspect the stylesheet request. Resize the window until it is near a phone width. Check that the words and rate table fit and that the focus outline is visible while tabbing to both links. A response script can verify status and delivered content; these visual and keyboard observations need a rendering environment. Record which checks you actually performed. Do not report a tested mobile layout if you only ran curl.

When done, stop the preview from the terminal where it runs. Confirm a repeat request fails to connect if that port remains unused. Keep the candidate scratch files only if you need them for the next authorized lesson. If disposing, check the unique path you created and remove its known training files, then remove only its empty folders. There is no cloud resource to delete. A web host or another process already using the port is outside this exercise.

Verify which files are prepared for the next lesson

Run the following file-tree check using Python 3 in the original shell or identify the same scratch directory yourself. The check builds a small manifest of ordinary files below the training root and compares it to the expected four entries. It does not read their content or send them anywhere. That makes it useful before choosing what to upload. The target root here must be the fresh training directory, not your full working folder or an existing server root.

test -n "${site_lab:-}" && SITE_SAMPLE_DIR="$site_lab" python3 - <<'PY'
from pathlib import Path
import os

root = Path(os.environ["SITE_SAMPLE_DIR"])
expected = {"index.html", "rates.html", "404.html", "css/style.css"}
actual = {str(path.relative_to(root)) for path in root.rglob("*") if path.is_file()}

for name in sorted(actual):
    print(name)
print("Missing:", sorted(expected - actual))
print("Extra:", sorted(actual - expected))
if actual != expected:
    raise SystemExit("Review the public file list before uploading.")
PY

The expected list is 404.html, css/style.css, index.html and rates.html. Both comparison fields should show empty lists. If the check finds a different name, inspect whether the file was saved under a wrong extension or directory. If a new extra file is an editor backup, decide whether it belongs outside the intended publication. The script deliberately reports differences. It does not remove anything or make a security decision about arbitrary files.

Make an approved small edit to the sample rate or visible release marker. Verify the new body at the expected URL after saving the exact file. A content edit can leave the manifest unchanged because it records file names. For release version control you can record the changed file's expected content or safe checksum under the publishing policy. Use complementary checks. A correct file list cannot prove correct values, and a visible 200 does not prove the publication contains only the intended files.

Each of the next methods should receive the same approved publication directory or artifact. Do not include binders, previous output, private keys or project credentials when preparing an archive. If a directory contains symbolic links, permissions or other entries outside this simple four-file model, handle them under the deployment's approved rules and inspect their actual destination. No file is published by running the manifest check.

Read the document with styles unavailable

Open the prepared rate page and first read its text without relying on color or position. “Sample milk rates” is the primary heading. The table caption identifies the values as practice data. Its column and row headers explain which value belongs to which product and unit. The main region contains the substantive content and the named site navigation offers the path back. A page should still make sense if its font, color or stylesheet becomes unavailable.

Links represent navigation to an address. Buttons are better for controls that perform an action on the current page when the app is built that way. The sample home and rates links should remain ordinary links. Their visible labels should identify a useful destination rather than a repeated vague phrase. The aria-current attribute on the matching link helps communicate the current location. Keep that marker consistent after copying the navigation block to another page. A visual sign alone can be missed by readers using a different display.

Test the heading order. The home page's primary heading names the dairy and the next level names the training content. Avoid choosing a heading number only because it looks smaller. Visual size can be set in CSS while the meaningful order stays understandable. If you add a section about visiting hours, give it a heading that states its purpose and put the hours in the appropriate content. The request and file path might be right while the document is still hard to read.

Try a keyboard walk. Start at the page, press Tab to reach the actual links and select the rates link using normal keyboard controls. Confirm the focus changes visibly, the intended destination loads and the new current location is clear. Repeat with a narrow preview. A missing outline or awkward text overflow is a different issue from a stylesheet 404. Inspect the actual page and applicable CSS rather than changing hosting settings to repair an accessibility or layout problem.

Explain which styles matched the element that looks wrong

A beginner sees a border and color on the home page but expects the milk price table to look the same width. Start with the browser's view of the selected element. A selector matches part of the document and assigns declarations to it. A rule on main sets its outer layout. Rules on table, th and td apply to elements within it. Some inherited text properties set on the body influence descendants. A border does not apply to every child merely because the enclosing box has one.

The stylesheet uses a width limited by available space and an upper bound. With a sufficiently wide viewport, the content remains within the maximum and automatic side margins center it. With a narrower screen, the available width becomes the limit. Because the example uses border-box sizing on the main layout elements, their padding and border count inside the width. If you add a long unbreakable word or fixed-width image, inspect that separate element rather than expecting the width declaration to solve every overflow.

When multiple rules apply, inspect which declaration the browser used. The cascade is the process that chooses among applicable declarations, including their importance and source, specificity and order under the applicable rules. For a simple exercise two equally prioritized rules for the same kind of element can be ordered so the later one takes effect. If a rule does not match the actual HTML, position in the file does not make it apply. Use the inspector to see both the selected rule and declarations that were overridden.

Colors should have adequate contrast for reading and focus. The practice page uses a dark foreground on a light background and a visible outline. If you change colors, measure the actual pair used and compare it with the relevant WCAG criteria for its text size and role. A border or topic label that looks fine to one tester can be hard to see for another. Verify meaning without depending only on color, especially for a rate change, current page or error state.

Keep literal text correct through the editor, shell and browser

The rates file contains a rupee symbol as a teaching example. Saving that file as UTF-8 and declaring the same encoding gives the browser a clear intention. The actual bytes still need to match it. If text looks garbled after transfer, verify the file from the source and the received response under the intended encoding. A declaration is not a converter. Re-saving in the correct format or correcting a conflicting server setting can be the relevant fix. A package or port change does not address this symptom.

HTML text and shell syntax have separate interpretation rules. A quoted shell heredoc protects the source text during file creation. In HTML, a literal left angle bracket intended as a visible less-than sign may need a character reference, such as &lt;, because raw brackets can begin markup. The browser parses the stored file after the shell has written it. Shell quoting does not make unsafe markup suitable for publication. What the learner typed and what the browser rendered should be compared at both stages.

Text copied from a formatted message can also include smart quotes or special spaces. A shell argument or HTML attribute may need plain quote delimiters in the actual source. If a pasted command fails, inspect the exact delimiters and visible line boundaries. If a page looks wrong but received the expected body, look at how the HTML parser interprets that source. A missing closing quote can make the resulting page and resources differ from what the author intended even when the server returns 200.

Use the browser’s source view and element inspector for two different observations. The response body shows the source bytes the client received under its encoding. The element inspector shows the document structure the browser built from them, which can include corrections or elements inserted by the parser. A page can appear readable despite malformed nesting. Do not interpret a document reorganization as proof that the server changed the file. Compare the raw response, parsed structure and visible behavior when the problem cannot be reproduced from one view alone.

Prepare one small validation exercise with two visible values, such as a local language word and the price symbol. Write down how the file is saved, what the document declares and what the browser should display. Observe the actual file and the permitted preview body. If a page needs user-supplied or exported data, use the project's approved escaping and rendering method rather than joining untrusted text into markup by hand. Here all values are fictional and entirely controlled by the exercise.

Compare edited source with the candidate files that will be served

Imagine the published exercise came from a workspace with a source file named rates-template.html and two generated directories. A learner changes the template and reloads the browser, but the new rate is absent. The server's active root might use the older build. Check how the source maps to the output and whether generation actually ran. Serving one file does not monitor every authoring file that could generate it. The simple heredoc exercise writes the candidate file directly, while a more complicated project may add a build stage.

Give the output a version you can identify before and after the change. For example, use a readable release label and a date of the fictional rate data. Keep the label consistent across the selected pages. Verify which watched directory or scratch server you used. If an expected update appears in the source editor but not in the HTTP response, first compare the supposed published file's contents. If that file is correct, compare the path, selected site and cache handling under the intended configuration.

Prepare an approved previous version as a recovery reference when a later lesson publishes files. A copy of only the home page is incomplete if the candidate changed rates, CSS and error behavior. A known release tree and its related configuration let the owner restore each required path. Keep the backup outside the serving root unless the site is explicitly authorized to serve it. A zipped previous release can contain private or outdated material and should not accidentally become an extra downloadable asset.

Record one intentional change using a before-and-after comparison of the candidate files. If the only intended update is a training price, show the old and new fictional values and any revision labels you changed. The navigation and stylesheet remain independent and should pass the same tests. A focused comparison makes it easier to explain whether a style difference came from an unexpected edit or a selected file. Keep the previous approved candidate separately so the comparison has an identifiable source.

When transferring the candidate, preserve the exact relative tree. Copying its parent can create an extra directory level, so /rates.html may fail while /candidate/rates.html exists. Copying only root HTML can leave the CSS subdirectory out. Build a small match between expected URL, expected file and intended root. That gives the next lesson a clear acceptance check. A successful command transferring some bytes says little about their final positions.

Fix the earliest incorrect observation before building the next part

Observed problemLikely first checkWorking outcome to verify
Terminal is waiting after a pasted code block.Check whether the closing delimiter was pasted on its own line with the matching label.The shell returns to its normal prompt and the intended file exists.
File is absent from the manifest.Check the chosen scratch path, directory and exact file name.Only the known release artifacts appear and each expected one is present.
HTML returns 200 but the browser looks unstyled.Inspect the stylesheet request's URL, status, type and body.The expected CSS resource loads and selected rules match the page.
A missing request shows the preview's default error text.Distinguish a plain preview server from a separately configured error-page deployment.The local missing request returns 404. Later verify the configured custom body.
A link returns 404 only after moving the page.Resolve its relative address from the new page directory and compare the published tree.The browser requests the intended exact file path under the published prefix.

These results can look similar if the only test is a browser screenshot. Use the shell's creation output and the file manifest before starting the listener. Test the listener before checking styling or navigation. Then read the network response for the resource that failed. Editing all parts at once makes it harder to know which correction mattered. The provided order gives you a local check before any copy or deployment affects a larger environment.

Prepare a short handoff for the first publish candidate

  1. Write the four intended relative file paths and give each a specific purpose. Then name two private items that should never enter the publication directory. Explain which owner supplies the approved data and how another student can check they have the right version.

  2. Give the expected URL for the same CSS link from two sibling pages, then for a page moved into a subdirectory. State what would have to change in the HTML or directory structure to keep the published asset available.

  3. Compare a direct request for 404.html with a request for the intentionally missing path. Include what both statuses mean in the simple Python preview and what the custom error configuration should show later. Provide the test that distinguishes an error page body from the status.

  4. Update the home and rates revision markers consistently and re-run the file and HTTP checks. Verify the title, heading, stylesheet and expected sample value. Show which observations came from shell output and which came from a real browser if you checked the rendered page.

Interview questions and worked answers

Why create and preview the files before transferring them?

It establishes the expected artifacts and local resource behavior in a narrow environment. A later failure can be compared against the known result. Debugging everything for the first time on a live server makes it harder to separate missing content from hosting configuration.

What does a quoted here-document marker change?

It keeps the body literal under the shell's documented rules, so characters meant for the page are not treated as shell expressions. The separate output path can still use the quoted scratch directory variable. The closing marker must match.

Why share one stylesheet between sibling pages?

The two pages can use a common visual layout through their relative links. The browser requests the file from its resolved address. If a page moves, revise or test the path instead of assuming the same text still points to the same asset.

When does a static 404 file return 200?

A direct request for that existing file can return a successful response. A real missing URL needs the error status determined by the active server configuration. Test the intended body and status at a missing path when you configure a custom error page.

What would you verify before uploading a build?

Check exact intended files, their layout, expected test responses and any sensitive or unrelated materials. A controlled publication directory lets you transfer only the files the public site needs. Then verify the same approved content at the destination.

Check the relationship between source text and the served files

  1. A new scratch directory was created. What are the next expected files? A. The intended pages and CSS. B. An unrelated site's keys and logs. C. A package repository and active AWS gateway.

    Show answer

    A. The publication tree contains the four sample files. Keep build tools, private notes and credentials outside the directory that visitors can reach.

  2. Which response proves that the CSS request actually returned the intended kind of file? A. The home page title exists. B. The CSS path returns a 200 with expected CSS content type and body. C. The host's SSH session is open.

    Show answer

    B. Assets are separate requests. The expected path, type and content describe the file delivered to the browser. A title or shell connection is unrelated to the asset response.

  3. Why should the reader use Python's local preview at loopback? A. To check actual HTTP resource responses without exposing an external listener. B. To obtain a public Elastic IP. C. To enable TLS without a certificate.

    Show answer

    A. Loopback limits this exercise to the local host while using real HTTP status, headers and paths. The preview is not a public app deployment.

  4. What is expected for the existing file /404.html when requested directly from the practice preview? A. A normal 200 with its direct document body. B. Always a network timeout. C. Always 404 because the file is named 404.

    Show answer

    A. The file exists and is served directly. An actual absent path has a different response. Later server configuration controls how an error document is used.

  5. Which test detects an unintended editor backup in the public candidate? A. Compare the expected set of file paths with the actual publication tree. B. Run a DNS lookup only. C. Change the stylesheet's main color.

    Show answer

    A. A file manifest can reveal extra material before publication. HTTP content checks and visual checks are still needed for the legitimate files.

Revision cards

Scratch directory
Use a unique local directory and keep the actual path. File writing belongs to that workspace.
Literal body
A quoted here-document delimiter preserves text. Its closing marker must match exactly.
Page structure
Give the document a useful title, visible headings, semantic content and clear links.
Shared assets
Verify the browser's resolved link, response status, type and correct file body.
Error status
A direct 404 file can return 200. Configure and test the missing route separately.
Publication list
Verify the intended output files and exclude private or unrelated material before upload.

References