This project provides a small Flask application that converts events from a Notion database into an iCalendar (.ics) feed.
-
Clone the repository
git clone <repo-url> cd NotionSynch
-
Create a virtual environment and install dependencies
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt -
Configure environment variables
The application reads its configuration from environment variables. Create a
.envfile in the project root or export the variables in your shell.Required variables:
NOTION_API_KEY– your Notion integration token.DATABASE_ID– the ID of the Notion database to read events from.
Optional variables:
PORT– port to run the Flask app on (defaults to5004).
Example
.envfile:NOTION_API_KEY=secret_... DATABASE_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx PORT=5004
-
Run the application
python notion_to_ics.py
The app will start and listen on
0.0.0.0:$PORT. You can then fetch your calendar feed fromhttp://localhost:$PORT/calendar.ics.
For deployments using a WSGI server (e.g. Gunicorn), use the wsgi.py module:
gunicorn wsgi:appThis project is licensed under the MIT License. See LICENSE for details.
This project provides a small Flask service that converts Notion calendar data to ICS format.
NOTION_API_KEY: Token for accessing the Notion API.DATABASE_ID: ID of the Notion database to read events from.PORT: Port the Flask application runs on (default:5004).NGROK_AUTH_TOKEN: Authentication token used by Ngrok to create secure tunnels. When using Ngrok, export this variable so the value can be injected intongrok.yml.
The ngrok.yml file contains Ngrok configuration and should not be committed with your secret token. The file is included in .gitignore. When running Ngrok you can supply your token via the NGROK_AUTH_TOKEN environment variable.
PythonAnywhere consoles include common source control tools like Git, so you can manage repositories directly from the web interface. If you want to clone a private GitHub repo, generate a key on PythonAnywhere and add the public part to your GitHub account:
ssh-keygen
cat ~/.ssh/id_rsa.pubFree accounts may only access a limited set of sites over HTTP/HTTPS or the pure git protocol. For repositories hosted on services such as GitHub or Bitbucket, make sure you use HTTPS URLs. GitHub requires a personal access token when pushing over HTTPS.
For more details, see the PythonAnywhere help page on using external version control.
To automatically pull new code and reload your web app whenever you push to GitHub,
use the update_webhook.py script included in this repository.
-
Add the webhook route Configure your PythonAnywhere WSGI file to use the webhook app:
from update_webhook import app as application
-
Set environment variables
GITHUB_WEBHOOK_SECRET: secret token configured in your GitHub webhook.WSGI_FILE: path to your PythonAnywhere WSGI file (defaults to/var/www/yourusername_pythonanywhere_com_wsgi.py).
-
Create a GitHub webhook
- Payload URL:
https://<your-username>.pythonanywhere.com/update - Content type:
application/json - Secret: same value as
GITHUB_WEBHOOK_SECRET - Trigger: “Just the push event.”
- Payload URL:
Whenever GitHub sends the webhook, PythonAnywhere will git pull the repository
and touch the WSGI file, causing the app to reload with the latest code.