Code Golf
Competition to write the shortest and fastest programs to solve problems in a variety of languages, including Javascript, Python, C++, and Java. Built on Flask (Python 3.6) and uses SQLAlchemy and Docker
Setup
Clone repository with
git clone https://github.com/ReflectionsProjections/rp2017-codegolf
Python
Navigate to main directory and install dependencies with
pip3 install -r requirements.txt
Docker
Install and set up Docker for your system link
- Add Docker to path variables, if not performed automatically by installer
- Test Docker install with
docker run hello-world
- If an error message appears, ensure that virtualization is enabled
- Ensure that Docker host is properly configured with
docker-machine ls
- There should be at least one host, called "default"
- Export environment variables with
eval "$(docker-machine env default)"
- For Windows, HyperV must be enabled
- If errors persist, run Docker as a VirtualBox image and try the above steps again
- Get list of current Docker images with
docker images
- Download the following images from Docker Hub if not already present:
node:boron
,python
,gcc
,java
- Other images can be downloaded with:
docker pull
- Download the following images from Docker Hub if not already present:
- Run containers from images
- Initialize a container with:
docker run -id python bash
. It will print a container ID to stdout - Get all running containers with:
docker ps
. The recently created Python container should appear - Kill the container with:
docker kill [id]
- This should not be necessary, since the server will automatically start and kill docker containers
- Initialize a container with:
Running
Deploy using Python
python3 app.py
Testing
A file of test HTTP requests is given in tests.json. This was automatically generated by Postman and should be tested there. Import collection into Postman and run all requests. All requests should return a 200 response, and be in JSON format. Requests marked "correct" should have correct=true
and requests marked "incorrect" hould have correct=false
.
Open using web browser on 0.0.0.0:21337
README IS STILL A WIP