apps/docs/content/guides/getting-started/quickstarts/flask.mdx
<$Partial path="quickstart_db_setup.mdx" />
Create a new directory for your Python app and set up a virtual environment.
mkdir my-app && cd my-app
python3 -m venv venv
source venv/bin/activate
Supabase's Agent Skills is a curated set of instructions that give your AI agent procedural knowledge about working with Supabase.
Install them so your AI coding agent can produce more accurate, reliable code using current Supabase patterns, such as authentication, server-side rendering, and database migrations, rather than relying solely on training data.
To install, run the following command in the root of your project:
npx skills add supabase/agent-skills
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.
pip install flask supabase
Create a .env file in your project root and populate it with your Supabase connection variables that you can get from the helper below, or from the project Connect panel:
SUPABASE_URL=<SUBSTITUTE_SUPABASE_URL>
SUPABASE_PUBLISHABLE_KEY=<SUBSTITUTE_SUPABASE_PUBLISHABLE_KEY>
<$Partial path="api_settings.mdx" variables={{ "framework": "flask", "tab": "frameworks" }} />
Install the python-dotenv package to load environment variables:
pip install python-dotenv
Create an app.py file and add a route that fetches data from your instruments table using the Supabase client.
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 = '<h1>Instruments</h1><ul>'
for instrument in instruments:
html += f'<li>{instrument["name"]}</li>'
html += '</ul>'
return html
if __name__ == '__main__':
app.run(debug=True)
Run the Flask development server, and go to http://localhost:5000 in your browser, you should see the list of instruments.
python app.py