Made with Supabase

ByteBlogger - Social Media Website

ByteBlogger is a dynamic and engaging social media platform designed to connect individuals, foster discussions, and share diverse content in a visually appealing and interactive manner.

Supabase and Flask Application

This code snippet demonstrates the setup and implementation of a Flask application with Supabase integration. Supabase is used to interact with a database, while Flask handles the web application framework.

Dependencies and Setup

The following dependencies are imported and configured at the beginning of the script:

  • supabase.create_client and Client from the Supabase library are imported to establish a connection with the Supabase database.
  • Flask is imported to create a web application using Flask.
  • timedelta from datetime is used to manage session lifetimes.
  • Various modules like os, json, load_dotenv, and flask_cors are imported for environment variables, JSON manipulation, and CORS handling.

Application Setup

  • An instance of the Flask application is created using Flask(__name__).
  • Environment variables are loaded using load_dotenv().

Supabase Connection

  • The Supabase URL and API key are retrieved from environment variables.
  • A Supabase client is created using create_client(url, key).

Application Configuration

  • Secret key and session lifetime are configured in the Flask app's configuration.

Cross-Origin Resource Sharing (CORS) Setup

  • Cross-Origin Resource Sharing is enabled for the Flask app using CORS(app).

Account Functions

  • Various functions are defined to interact with Supabase and retrieve account-related data.
  • access_username_mapping_database() retrieves data from the 'username_mapping' table.
  • organize_into_accounts() organizes retrieved data into a list of account dictionaries.
  • Functions like get_all_accounts(), find_username_by_email(email), and find_uuid_by_email(email) provide different account-related functionalities.

Thread Functions

  • Similar to the account functions, thread-related functions are defined to retrieve and organize data from the 'blog_posts' table.
  • Functions like access_blog_database(), blog_data_by_date(), and organize_blog_data() handle blog post data retrieval and organization.
  • get_all_posts_and_comments() returns lists of posts and comments.
  • get_all_threads() organizes posts and related comments into thread dictionaries.

Related Projects


A project by Zernonia