In this lecture project, you will be implementing an HTTP scavenger hunt. Players will play by changing the URL in their browser.
For example, a player will start a game at localhost:8000/, which says “Clue: the number of the course you are currently taking”, meaning that the player knows to go to localhost:8000/485.
Download the starter files and extract it into a folder of your choice. Use these commands, based on the P1 virtual environment tutorial to create a virtual environment and install the dependencies.
$ pwd
/home/jklooste/lec0102
$ python3 -m venv env
$ source env/bin/activate
$ pip install -r requirements.txt
$ pip install -e .
At this point, the following command should work:
$ scavenger_hunt sample_game/
Visit localhost:8000 in your browser, where it should show “Hello, world!”.
In scavenger_hunt/__main__.py, implement a web server that loads a game from the input directory passed as a command line argument. The paths and responses for the game are in the file game.json. Use the json library to load this data and pass it to the ScavengerHuntHTTPRequestHandler.
There are two types of responses: one with hard-coded text in the JSON, and another that loads a page from a file.
Your implementation works correctly if scavenger_hunt sample_game/ serves the following results:
localhost:8000/: “Clue: the number of the course you are currently taking”localhost:8000/485: “You win!”Create your own scavenger hunt in a separate directory. Use both text and file clues.