by yayitaster
Google Calendar Voice Notifications
import logging
from gunicorn.app.base import BaseApplication
from app_init import create_initialized_flask_app
# Flask app creation should be done by create_initialized_flask_app to avoid circular dependency problems.
app = create_initialized_flask_app()
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class StandaloneApplication(BaseApplication):
def __init__(self, app, options=None):
self.application = app
self.options = options or {}
super().__init__()
def load_config(self):
# Apply configuration to Gunicorn
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
def load(self):
Created: | Last Updated:
Introduction to the Template
This template helps you build an application that integrates with Google Calendar to fetch and display upcoming events. The app also has plans for voice notifications using artificial voices. The template includes a mobile and desktop header, a home page, and routes for Google OAuth authentication and fetching calendar events.
Clicking Start with this Template
To get started with this template, click Start with this Template in the Lazy Builder interface.
Test
Press the Test button to begin the deployment of the app. This will launch the Lazy CLI, and you will be prompted for any required user input.
Entering Input
After pressing the Test button, you will be prompted to provide user input through the Lazy CLI. Follow the steps below to set up the necessary integrations:
-
Google OAuth Setup:
- You need to set up Google OAuth to allow the app to access your Google Calendar.
- Go to the Google Cloud Console.
- Create a new project or select an existing project.
- Navigate to APIs & Services > Credentials.
- Click Create Credentials and select OAuth 2.0 Client IDs.
- Configure the OAuth consent screen and set up the OAuth 2.0 Client ID.
- Add the following redirect URI:
http://localhost:8080/login/authorized
. - Copy the Client ID and Client Secret.
-
Environment Secrets:
- In the Lazy Builder, go to the Environment Secrets tab.
- Add the following secrets:
GOOGLE_CLIENT_ID
: Your Google OAuth Client ID.GOOGLE_CLIENT_SECRET
: Your Google OAuth Client Secret.FLASK_SECRET_KEY
: A secret key for Flask sessions (you can generate a random string for this).
Using the App
Once the app is deployed, you can use the interface as follows:
-
Home Page:
- The home page will display a welcome message and a button to connect your Google Calendar.
- Click the Connect Google Calendar button to initiate the OAuth flow.
-
Google OAuth Flow:
- You will be redirected to the Google login page to authorize the app.
- After authorization, you will be redirected back to the app, and your upcoming events will be fetched and displayed.
-
Viewing Events:
- The app will display your upcoming events fetched from Google Calendar.
- You can log out by clicking the Logout button.
Integrating the App
To integrate the app with your Google Calendar, follow these steps:
-
Authorize the App:
- Click the Connect Google Calendar button on the home page.
- Authorize the app to access your Google Calendar.
-
Fetch and Display Events:
- After authorization, the app will fetch your upcoming events and display them on the page.
Sample Code for External Integration
If you need to integrate the app with another tool, you can use the following sample code to make a request to the app's server:
Sample Request
```python import requests
response = requests.get('http://localhost:8080/calendar_events') print(response.json()) ```
Sample Response
json
[
{
"summary": "Event 1",
"start": {
"dateTime": "2023-10-01T10:00:00Z"
},
"end": {
"dateTime": "2023-10-01T11:00:00Z"
}
},
{
"summary": "Event 2",
"start": {
"dateTime": "2023-10-02T14:00:00Z"
},
"end": {
"dateTime": "2023-10-02T15:00:00Z"
}
}
]
By following these steps, you can successfully set up and use the Google Calendar Voice Notifications app template.