README.md 2.63 KB
Newer Older
1
# ungleich_hack_3
2

3
A micro project proposed as a solution for [Hack 3: IPv6 cat](https://ungleich.ch/u/projects/jobs-hacks-bounties/) from [ungleich](https://ungleich.ch/).
4

coox's avatar
coox committed
5
## Overview
6

coox's avatar
coox committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Per requirements, the project behaves differently depending on the version of the [Internet Protocol](https://en.wikipedia.org/wiki/Internet_Protocol) used to navigate it:

- Via IPv4, it shows a static page saying "Sorry, only reachable by IPv6"
- Via IPv6, it shows a friendly cat picture

To determine which version is used, we examine the visitor’s IP address. This is done in a [middleware](require_ipv6) that responds with an error page to non-IPv6 requests.

If the request goes through, a simple [application](friendly_cat) can be accesses, with a single index view showing a friendly picture of a cat.

## Usage

To install and run the project on your own computer, you must ensure that the following prerequisites are fulfilled:

- your operating system [supports IPv6](https://en.wikipedia.org/wiki/Comparison_of_IPv6_support_in_operating_systems)
- you can run [Python](https://www.python.org/) version 3.6 or above (it is recommended to use a [virtual environment](https://docs.python.org/3/tutorial/venv.html)), with:
    - [`pip`](https://pip.pypa.io/)
    - [`setuptools`](https://pypi.org/project/setuptools/)
- you can run the [`make`](https://www.gnu.org/software/make/) command

Proceed to [cloning](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) this repository, and navigate to its directory.

Then, execute the following command to install the project’s required modules:
29 30

```sh
31
make install
32
```
coox's avatar
coox committed
33 34 35 36 37 38 39 40 41

Then, execute the following command to run the project using Django’s built-in web server:

```sh
make run
```

You can then navigate the project at [http://localhost:8000/](http://localhost:8000/).

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
## Deployment

To install and run the project in production, you must ensure that the following extra prerequisites are fulfilled:

- you can run an [WSGI](https://www.python.org/dev/peps/pep-3333/) server with IPv6 support to expose the project’s [`application`](https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/#the-application-object)
- you can run a web server with IPv6 support to act as a file server for the project’s static files, and as a reverse proxy between the WSGI server and the internet

Proceed to deploying this repository, and navigate to its directory.

Then, execute the following command to install the project’s static files:

```sh
make build
```

Then, configure and run your WSGI server and your web server.

coox's avatar
coox committed
59 60 61
## Hacking

See [CONTRIBUTING](CONTRIBUTING.md) for developer documentation.