Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Python HTTP Server

This directory contains a Python HTTP server running on Unikraft that provides a simple response to each request.

Set Up

To run this example, install Unikraft's companion command-line toolchain kraft, clone this repository and cd into this directory.

Run and Use

Use kraft to run the image and start a Unikraft instance:

kraft run --rm -p 8080:8080 --plat qemu --arch x86_64 -M 256M .

If the --plat argument is left out, it defaults to qemu. If the --arch argument is left out, it defaults to your system's CPU architecture.

Once executed, it will open port 8080 and wait for connections. To test it, you can use curl:

curl localhost:8080

You should see a "Bye, World!" message.

Inspect and Close

To list information about the Unikraft instance, use:

kraft ps
NAME                      KERNEL                          ARGS        CREATED         STATUS   MEM   PORTS                   PLAT
inspiring_davidgreybeard  oci://unikraft.org/python:3.10  /server.py  16 seconds ago  running  244M  0.0.0.0:8080->8080/tcp  qemu/x86_64

The instance name is inspiring_dadidgreybeard. To close the Unikraft instance, close the kraft process (e.g., via Ctrl+c) or run:

kraft rm inspiring_dadidgreybeard

Note that depending on how you modify this example your instance may need more memory to run. To do so, use the kraft run's -M flag, for example:

kraft run --rm -p 8080:8080 --plat qemu --arch x86_64 -M 512M .

kraft and sudo

Mixing invocations of kraft and sudo can lead to unexpected behavior. Read more about how to start kraft without sudo at https://unikraft.org/sudoless.

Learn More