Index āŗ 1. Static HTML
Make your first static āHello, world!ā Kitten page using plain old HTML.
Topics covered
- How to run Kitten.
- The basics of how to use the Kitten server in development.
- How to create a static HTML page.
Letās quickly create and test your first āHello, world!ā Kitten site.
Create a directory for the example and enter it:
mkdir kitten-playground cd kitten-playground
Create a file called index.html and add the following content to it:
<h1>Kitten</h1> <p>š±ļø</p>
Run Kitten using the following syntax:
kitten
Once Kitten is running, hit https://localhost, and you should see your new site.
š” When you run
kitten
without any arguments, it defaults to serving the current directory. You can also specify a path as the first argument (kitten [path to serve]
) to serve a different directory than the one youāre currently in.š” Notice that you didnāt get a certificate error. This is because Kitten automatically creates a development-time TLS certificate for your local machine signed by a local certificate authority that it adds to your systemās trust store (and to Firefox, if you have it installed) using Auto Encrypt Localhost.
(If youāre running on Windows under WSL 2 and you do get a certificate error, please remember to manually install the local development certificates in your browsers.)
š” Youāre not limited to accessing your local machine via https://localhost. You can also use any local IP address that itās accessible from (see Accessing your local machine from other devices on your local area network for more information). You can also use the IP aliases 127.0.0.2 - 127.0.0.4 and localhost aliases (subdomains) place1.localhost - place4.localhost without certificate errors. The latter, especially, are useful when testing the peer-to-peer features of Small Web apps.
š” Small Web places made with Kitten are meant to be owned and used by one person. Until an identity and secret has been generated for this person, Kitten will display a link to the special page that generates them. (Your secret on a Small Web place never hits the server.) You can also generate this secret from Kittenās REPL using the
.id create
command.)š” By default, Kitten will be as quiet as possible and only surface warnings and errors. If you want more extensive logging, start it with the VERBOSE environment variable set:
VERBOSE=true kitten [path to serve]
Similarly, if you want to see performance statistics, set
PROFILE=true
.Note that the first time Kitten is run, it will create a TLS certificate authority and add it to your system trust stores as well as to Firefox and Chrome so you can run your development environment from https://localhost to match the deployment environment as closely as possible. Your operating system will ask your permission before allowing this.
So weāve seen how Kitten happily serves any HTML you throw at it just like any good web server should.
But you can render HTML using any old web serverā¦
Letās start doing things no other web server can do, shall we?
Next tutorial: Dynamic Pages