by Kevin Cao, Andy Lin, Austin Ngan, Shadman Rakib
Making a game akin to Hasbro’s BATTLESHIP, a game that uses the classic rules for Battleship and adds some twists to the game, using differently shaped ships, maps and abilities.
Kevin: Project Manager & VM(Digital Ocean Droplet) & Frontend (registering clicks/UI)
Andy: Frontend (board management)/ digital ocean debugger
Austin: Backend (Leaderboard DB, connection between frontend and backend)
Shadman: Frontend (registering hits, changing maps, abilities)
Working Demo: http://67.207.95.192/
git clone https://github.com/kcao20/battleship.git
python3 -m venv venv
source venv/bin/activate
cd battleship
pip3 install -r requirements.txt
cd app
python3 __init__.py
5. Open up the url given by the terminal: [http://127.0.0.1:5000/]
This guide assumes you have a working vm and apache set up. https://github.com/kcao20/workshop/blob/main/24_LAMP/README.md
sudo apt-get install libapache2-mod-wsgi-py3
sudo a2enmod wsgi
cd /var/www
sudo mkdir FlaskApp
sudo chown <username> FlaskApp
sudo chgrp -R www-data FlaskApp
sudo chmod g+s FlaskApp
cd FlaskApp
git clone https://github.com/kcao20/battleship.git
mkdir FlaskApp && cp -r battleship/app/* battleship/requirements.txt FlaskApp
sudo apt install python3.8-venv
python3 -m venv venv
source venv/bin/activate
cd FlaskApp
pip3 install -r requirements.txt
sudo nano /etc/apache2/sites-available/FlaskApp.conf
Add:
<VirtualHost *:80>
ServerName yourdomain.com
ServerAdmin youemail@email.com
WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
<Directory /var/www/FlaskApp/FlaskApp/>
Order allow,deny
Allow from all
</Directory>
Alias /static /var/www/FlaskApp/FlaskApp/static
<Directory /var/www/FlaskApp/FlaskApp/static/>
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
cd /var/www/FlaskApp
nano flaskapp.wsgi
Add:
#!/usr/bin/python
python_home = '/var/www/FlaskApp/venv'
import sys
import site
# Calculate path to site-packages directory.
python_version = '.'.join(map(str, sys.version_info[:2]))
site_packages = python_home + '/lib/python%s/site-packages' % python_version
# Add the site-packages directory.
site.addsitedir(site_packages)
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
sys.path.insert(0,"/var/www/FlaskApp/FlaskApp/")
from FlaskApp import app as application
application.secret_key = 'something super SUPER secret'
sudo a2ensite FlaskApp.conf
systemctl reload apache2
When apache2 tries opening/writing to the database, it often fails.
To fix, use the absolute path for the database and any other files you try to open that are not static.