""" Main demo page resource for the OpenEventDatabase. """ import falcon from oedb.utils.logging import logger class DemoMainResource: """ Resource for the main demo page. Handles the /demo endpoint. """ def on_get(self, req, resp): """ Handle GET requests to the /demo endpoint. Returns an HTML page with a MapLibre map showing current events. Args: req: The request object. resp: The response object. """ logger.info("Processing GET request to /demo") try: # Set content type to HTML resp.content_type = 'text/html' # Load environment variables from .env file for OAuth2 configuration from oedb.utils.db import load_env_from_file load_env_from_file() # Get OAuth2 configuration parameters import os client_id = os.getenv("CLIENT_ID", "") client_secret = os.getenv("CLIENT_SECRET", "") client_redirect = os.getenv("CLIENT_REDIRECT", "") # Create HTML response with MapLibre map html = """ OpenEventDatabase Demo
×

Une erreur s'est produite lors du chargement des événements.

Consultez le forum OSM pour plus d'informations.

Feedback sur le forum OSM

OpenEventDatabase Demo

This map shows current events from the OpenEventDatabase.

+ Traffic event

+ Any Event

Information Panel

API Endpoints:

Demo Pages:

sources

""" # Set the response body and status resp.text = html resp.status = falcon.HTTP_200 logger.success("Successfully processed GET request to /demo") except Exception as e: logger.error(f"Error processing GET request to /demo: {e}") resp.status = falcon.HTTP_500 resp.text = f"Error: {str(e)}" # Create a global instance of DemoMainResource demo_main = DemoMainResource()