From 2283c38e3da2509f020f21df0d4b72f75ce6d50a Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 17 Dec 2025 09:24:21 +0900 Subject: [PATCH] docs: Add Flask(Python) quick start guide (#40746) * feat: Add Flask quick start * feat: Add Flask (python) quick start to the menu * Small changes --------- Co-authored-by: Chris Chinchilla --- .../NavigationMenu.constants.ts | 6 +- .../getting-started/quickstarts/flask.mdx | 154 ++++++++++++++++++ 2 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 apps/docs/content/guides/getting-started/quickstarts/flask.mdx diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts index b3bf6082e62..9fc45bcbbde 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts @@ -375,6 +375,11 @@ export const gettingstarted: NavMenuConstant = { name: 'SvelteKit', url: '/guides/getting-started/quickstarts/sveltekit' as `/${string}`, }, + { + name: 'Flask (Python)', + url: '/guides/getting-started/quickstarts/flask' as `/${string}`, + enabled: !jsOnly, + }, { name: 'TanStack Start', url: '/guides/getting-started/quickstarts/tanstack' as `/${string}`, @@ -389,7 +394,6 @@ export const gettingstarted: NavMenuConstant = { url: '/guides/getting-started/quickstarts/ruby-on-rails' as `/${string}`, enabled: !jsOnly, }, - { name: 'SolidJS', url: '/guides/getting-started/quickstarts/solidjs', diff --git a/apps/docs/content/guides/getting-started/quickstarts/flask.mdx b/apps/docs/content/guides/getting-started/quickstarts/flask.mdx new file mode 100644 index 00000000000..4944233d846 --- /dev/null +++ b/apps/docs/content/guides/getting-started/quickstarts/flask.mdx @@ -0,0 +1,154 @@ +--- +title: 'Use Supabase with Python' +subtitle: 'Learn how to create a Supabase project, add some sample data to your database, and query the data from a Python app.' +breadcrumb: 'Framework Quickstarts' +hideToc: true +--- + + + + + + <$Partial path="quickstart_db_setup.mdx" /> + + + + + + + + Create a new directory for your Python app and set up a virtual environment. + + + + + + ```bash name=Terminal + mkdir my-app && cd my-app + python3 -m venv venv + source venv/bin/activate + ``` + + + + + + + + + The fastest way to get started is to use Flask for the web framework and the `supabase-py` client library which provides a convenient interface for working with Supabase from a Python app. + + Install both packages using pip. + + + + + + ```bash name=Terminal + pip install flask supabase + ``` + + + + + + + + + Create a `.env` file in your project root and populate it with your Supabase connection variables: + + + + + + + + + + <$CodeTabs> + + ```text name=.env + SUPABASE_URL= + SUPABASE_PUBLISHABLE_KEY= + ``` + + + + <$Partial path="api_settings_steps.mdx" variables={{ "framework": "", "tab": "" }} /> + + + + + + + + + Install the `python-dotenv` package to load environment variables: + + ```bash + pip install python-dotenv + ``` + + Create an `app.py` file and add a route that fetches data from your `instruments` table using the Supabase client. + + + + + ```python name=app.py + import os + from flask import Flask + from supabase import create_client, Client + from dotenv import load_dotenv + + load_dotenv() + + app = Flask(__name__) + + supabase: Client = create_client( + os.environ.get("SUPABASE_URL"), + os.environ.get("SUPABASE_PUBLISHABLE_KEY") + ) + + @app.route('/') + def index(): + response = supabase.table('instruments').select("*").execute() + instruments = response.data + + html = '

Instruments

    ' + for instrument in instruments: + html += f'
  • {instrument["name"]}
  • ' + html += '
' + + return html + + if __name__ == '__main__': + app.run(debug=True) + ``` + +
+ +
+ + + + + Run the Flask development server, go to http://localhost:5000 in a browser and you should see the list of instruments. + + + + + + ```bash name=Terminal + python app.py + ``` + + + + +
+ +## Next steps + +- Set up [Auth](/docs/guides/auth) for your app +- [Insert more data](/docs/guides/database/import-data) into your database +- Upload and serve static files using [Storage](/docs/guides/storage)