A simple PWA to share your thoughts.
These instructions will guide you through setting up and running the Thought Stream application on a Raspberry Pi.
- A Raspberry Pi with Raspberry Pi OS installed.
- An internet connection.
gitinstalled (sudo apt-get install git).
Clone this repository to your Raspberry Pi:
git clone <repository_url>
cd thought_streamThe application requires Python 3 and some dependencies.
Install Python 3 and pip:
sudo apt-get update
sudo apt-get install python3-venv python3-pipCreate a virtual environment and install the dependencies:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtThe application uses a .env file to manage sensitive configurations like your username, password, and the VAPID claims email for push notifications. This keeps your secrets out of the code and Git repository.
-
Create your
.envfile:cp .env.example .env
-
Edit the
.envfile:nano .env
Replace the placeholder values with your desired username, a strong password, and a valid email address (e.g.,
mailto:your-email@example.comorhttps://your-website.com) for theVAPID_CLAIMS_EMAIL.Example
.envcontent:APP_USERNAME=mysecureuser APP_PASSWORD=My$uper$ecureP@ssw0rd! VAPID_CLAIMS_EMAIL=mailto:my.contact@example.comSave and exit (
Ctrl+X, thenY, thenEnter).
The application uses VAPID keys for push notifications. You need to generate these keys once.
python generate_keys.pyThis will create a vapid_keys.json file.
Important: Do not share your vapid_keys.json file publicly.
To run the application, execute the following command:
python app.pyThe application will be running on http://<your_pi_ip>:5000.
To access your application from the internet, you can use a Cloudflare Tunnel.
-
Install
cloudflaredon your Raspberry Pi.Follow the official Cloudflare documentation to install
cloudflared: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation/ -
Authenticate
cloudflared:cloudflared tunnel login
-
Create a tunnel:
cloudflared tunnel create thought-stream-tunnel
This will give you a UUID for your tunnel and create a credentials file.
-
Create a configuration file:
Create a file named
config.ymlin/etc/cloudflared/(you may need to create the directory).tunnel: <your_tunnel_uuid> credentials-file: /root/.cloudflared/<your_tunnel_uuid>.json ingress: - hostname: your-subdomain.your-domain.com service: http://localhost:5000 - service: http_status:404
Replace
<your_tunnel_uuid>with the UUID from the previous step, andyour-subdomain.your-domain.comwith the domain you want to use. -
Route DNS to the tunnel:
cloudflared tunnel route dns thought-stream-tunnel your-subdomain.your-domain.com
-
Run the tunnel:
cloudflared tunnel run thought-stream-tunnel
You can also run the tunnel as a service to have it start automatically on boot. See the Cloudflare documentation for details.
You should now be able to access your Thought Stream application from the internet at https://your-subdomain.your-domain.com.
- Open the application in your browser.
- Click the "Subscribe to Notifications" button.
- Your browser will ask for permission to show notifications. Click "Allow".
You will now receive a push notification every time a new thought is posted.