Tic-Tac-Toe game (https://en.wikipedia.org/wiki/Tic-tac-toe) is a classic two player game that I love playing with my kids.
I built this app using Python 3.5, but tested in Python 2.7 as well.
The Comamnd line version does not require any packages. The Web version requires Tornado 4 as specified in the requirements.txt
Navigate to board_games folder, then run from your terminal -
python run_tic_tac_toe.py
-
Create a Virtual Environment -
pyvenv venv
. For Python2, installvirtualenv venv
-
Activate Virtual Environment -
source venv/bin/activate
. For Windows, you may needvenv/scripts/activate
. -
Install Requirments -
pip install -r requirements.txt
. This will install Tornado Web Framework. -
Run the App -
python run.py
-
Open two browser Tabs for
http://localhost:9000
and Play the game.
ssh -i <your AWS Pem key file> ubuntu@<aws ip>
sudo apt-get update
sudo apt-get upgrade
# Install GIT
sudo apt-get install git
# Install Make
sudo apt-get install make
# Install Python 3
# Go to https://www.python.org/downloads/ and copy link to Python3
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar zxvf Python-3.5.2.tgz
cd Python-3.5.2
./configure
make
sudo make install
# Now test to make sure python3 is installed.
python3 <enter>
# Once that's confirmed, we don't need the installers anymore. We can delete them.
cd ..
rm Python-3.5.2.tgz
sudo rm -rf Python-3.5.2/
# Go to home directory
cd ~
# Create Projects folder where we will clone our app
mkdir projects
cd projects
git clone https://github.com/sampathweb/board-games-app.git
cd board-games-app
# Create Virtual Environment
pyvenv venv
source venv/bin/activate
# Install required packages for the app
pip install -r requirements.txt
# Test by running the app at command line
python run.py (Confirm that App is running)
We want to serve the App under a Supervisor process so that we can Start / Stop and log errors in the app.
Let's install and configure Supervisor.
sudo apt-get install supervisor
sudo vi /etc/supervisor/conf.d/board-games-app.conf
<press i insert mode>
[program:board-games-app]
autostart = true
autorestart = true
command = /home/ubuntu/projects/board-games-app/venv/bin/python /home/ubuntu/projects/board-games-app/run.py --debug=False --port=80
numprocs = 1
startsecs = 10
stderr_logfile = /var/log/supervisor/board-games-app-err.log
stdout_logfile = /var/log/supervisor/board-games-app.log
environment = PYTHONPATH="/home/ubuntu/projects/board-games-app/venv/bin/"
<escape :wq>
sudo supervisorctl reload
# Verify that App is running under Supervisor.
# You may need to wait to few seconds for it go from Starting to Running
sudo supervisorctl status
<Your APP is live now>
Open Browser: http://<AWS IP>
(App is Live!)
Congratulations you have deployed your App