NSWI142: Web Applications

Browser, tools, and a static website

Preliminaries

Please read this section at least one day prior to the seminar. This section outlines what you are expected to know, be able to do, or prepare in advance. Following these instructions will help you get the most out of the seminar and ensure smooth participation.

Preliminaries 1 / 1

Before the start of the practical, you should be able to:

  • Create a simple HTML file on your machine.
  • Use editor of choice to edit the HTML file.

Agenda

  • Organization
  • Demonstration: Browser
  • Exercise: Static website
  • Demonstration: Selected tools: ssh, scp, curl
  • Demonstration: Webhosting
  • Exercise: Upload your website to webik

Demonstration: Credit Requirements

In this section we briefly recap what you need to do in order to get the credit.

Credit Requirements 1 / 1

In order to get a credit you need to:

  • successfully solve mandatory homework assignments,
  • pass the credit test,
  • implement semestral project.

During the practicals you can collect points for active participation and solving homeworks. By collecting enough points you can improve your final grade or even pass without the need to take the final exam.

For more details see grading.

Demonstration: Browser

You have probably used a web browser before. In this section we focus on so called "developer tools" and what they allow you to do.

Basics

Try to open an HTML file from a local file and using http, https protocol.

Pick a website and inspect the source code. You can even pick the default content in a new tab and see what is there.

  • ctrl + u (Chrome, Firefox,Brave, Edge, ..)
  • open context menu (right click) and select "View page source"
  • ...

Developer tools

In most modern browsers you can open a developer tools console. There are multiple ways to do so.

  • open context menu (right click) and select "Inspect".
  • F12
  • ctrl + shift + i
  • ...

Explore Elements, Network and Application tab.

Exercise: Static website

Create a simple static website as a single HTML file. You should already know how to do this. Before you start, please read instruction on following slides and proceed accordingly.

Create a static website

Create a local file "content.html". Add a header, a paragraph, a link, a footer, and a button with no action into the website. The link should be in the header. The footer should contain copyright notice. Add following content to the website <hr>, so it is visible in this form.

Use inline CSS to change header text color to red.

Open the website in a browser of choice and check everything as it should be.

Continue to the next slide once you are done.

Semantic HTML elements

Use following semantic elements in you website:

Continue to the next slide once you are done.

Validation

Utilize validator.w3.org to validate your website and fix any errors or warning. Use "Validate by File Upload" or "Validate by Direct Input" option.

Continue to the next slide once you are done.

Task Complete

Congratulations, if you have followed the instructions, you have just reached the end of this exercise.

Debriefing

  • Any issues?
  • Why we need validation? Can browser handle an invalid document?

Demonstration: Tools

In this section we recap some of the tools you already know, namely ssh and scp. We also add a new one to make HTTP requests.

ssh

There is an alternative for Windows called Putty. Make sure you know how to:

  • Connect to remove server.
  • Proxy remote port to localhost.

scp

There is an alternative for Windows called WinSCP. Make sure you know how to:

  • Copy a file to a remove server.
  • Copy a directory to a remove server.

curl

Command line tool to make HTTP requests. It is available on Linux, macOS, and Windows. PowerShell implementation is different!

  • Execute HTTP GET request.
  • Execute HTTP POST request.
  • Send JSON file using HTTP POST request.

You can test against a simple PHP script.

Send the same data as this form.

Demonstration: Webhosting

localhost

You can host your website locally. This is quick and easy way to develop and test a website.


      # Python
      python -m http.server 8080

      # PHP
      php -S 127.0.0.1:8080
    

webik.ms.mff.cuni.cz

You can host your website at https://webik.ms.mff.cuni.cz/~<username>/. This servere is provided by NSWI142, do not use or abuse it for anything else! You should have received username and password by e-mail.

Connect using SSH to get access to shell:

        ssh -p 42222 <username>@webik.ms.mff.cuni.cz
      

Copy file index.html from local machine to webik:

        scp -P42222 index.html <username>@webik.ms.mff.cuni.cz:public_html/
      

ms.mff.cuni.cz

You can host your website at https://www.ms.mff.cuni.cz/~<username>/. This service has nothing to do with NSWI142.

The following information is based on NSWI177.

  • SU1 : u1-1.ms.mff.cuni.cz - u1-14.ms.mff.cuni.cz
  • SU2 : u2-2.ms.mff.cuni.cz - u2-5.ms.mff.cuni.cz
  • Rotunda : u-pl1.ms.mff.cuni.cz - u-pl2.ms.mff.cuni.cz

The computers in Lab SU1 and SU2 can not be connected to via SSH during the day (or more specifically during the scheduled classes). That is to prevent remote users to interfere with classes. Rotunda lab machines are accessible 24/7.

Exercise: Upload your website to webik

The objective is to create a simple personal website and publish it using webik.

Create a personal websites

Create a personal website presenting you as a student or a made up person / character. You need to have a landing page (./personal/index.html), about page (./personal/about.html) and projects page (./personal/projects.html). They all need to be interlinked using relative links. You are free to use external CSS of your choice or create your own. The landing page must be available at https://webik.ms.mff.cuni.cz/~<username>/personal/.

Make sure that the HTML is valid!

Do not use any JavaScript!

Upload all the files into your public_html directory. Make sure that all the websites work.

Resources

In this section you can find additional resources connected to the topic of this practical.

Resources

Questions, ideas, or any other feedback?

Please feel free to use the anonymous feedback form.