This website is a hub for web scraping applications making automatic reservation bookings. Yugi Books is built using the Python Flask web framework, Selenium fro web scraping, Pushover for sending mobile device notifications, and Docker, NGINX, and a Raspberry Pi for deployment over a local network.
Current Yugi Books applications:
- Birdie Blitz: golf tee time alerts for select Southern California courses
- Go to Pushover and create an account. Note the user key displayed on your account dashboard.
- Create an application "Birdie Booker". Note the application key displayed on the application dashboard.
- Install Pushover on your mobile device and login.
- (Optional) In the application dashboard, create a subscription to allow multiple people to join the app. In later steps, use the group key instead of the user key.
For production, this Yugi Books is deployed over a local network by a Raspberry Pi using NGINX. All Docker setup is done on the Raspberry Pi via an SSH connection.
- Install Rasberry Pi OS version 11 (Bullseye) or higher.
- Install Docker using this tutorial: https://docs.docker.com/engine/install/raspberry-pi-os/
- Set a static IP for the Raspberry Pi by following this tutorial: https://www.tomshardware.com/how-to/static-ip-raspberry-pi
- Note the static IP for Docker setup.
To run in the production environment, replace compose.dev.yml
with compose.prod.yml
.
-
Open Docker on your machine.
-
Clone the repository and cd into
yugi-books
.git clone https://github.com/ajtadeo/yugi-books.git cd yugi-books
-
Create
.env.dev
and.env.prod
.env.dev
FLASK_APP=app/__init__.py FLASK_DEBUG=1 PORT=5000 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 SECRET_KEY=s3cret CSRF_SECRET=s3cret PUSHOVER_API_KEY=s3cret PUSHOVER_USER_KEY=s3cret
.env.prod
FLASK_APP=app/__init__.py FLASK_DEBUG=0 PORT=4000 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 SECRET_KEY=s3cret CSRF_SECRET=s3cret PUSHOVER_API_KEY=s3cret PUSHOVER_USER_KEY=s3cret
-
In
web/app/birdie_booker
createbirdie_booker.db
-
In the root directory, start the server.
docker compose -f compose.dev.yml up --build
-
Open Yugi Books in your browser
- Dev:
<Raspberry Pi IP>:5001
- Production:
<Raspberry Pi IP>:1337
- Dev:
-
Stop the server.
docker compose -f compose.dev.yml down -v
Helpful Docker Commands
docker logs [container name]
- View a container's logs.
docker ps -a
- List all containers, including inactive ones.
docker image list
- List all images
Sometimes it's easier to host Yugi Books as a normal Flask app without Docker, especially if the developer's changes cause frequent application crashes. These crashes cause the docker container to immediately shut down, so re-composing the container can get tiring. These hosting steps are an alternate option for situations with frequent crashing.
- Install the latest Chrome for Testing and Chromedriver versions for your OS.
- Download Chrome for Testing and Chromedriver from this site.
- Move
Chrome for Testing
into the same directory aschromedriver
- Append
export PATH=/path/to/chromedriver
to your run command file, usually.bashrc
for MacOS.
- Clone the repository and cd into
web
. Stay in this directory for the remainder of setup.git clone https://github.com/ajtadeo/yugi-books.git cd yugi-books/web
- Create
.flaskenv
and add the following credentials:FLASK_APP=app/__init__.py FLASK_DEBUG=1 HOST='127.0.0.1' PORT=5000 PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 SECRET_KEY=s3cret CSRF_SECRET=s3cret PUSHOVER_API_KEY=s3cret PUSHOVER_USER_KEY=s3cret
- Set up the virtual environment using venv.
python3 -m venv venv source venv/bin/activate pip3 install -r requirements.txt
- Start the server.
run flask
- Open Yugi Books in your browser at
127.0.0.1:5001