-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from emmanueposu/jbranch3
Jbranch3
- Loading branch information
Showing
28 changed files
with
87 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Python application | ||
|
||
on: [push, pull_request] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Test with Unittest | ||
run: | | ||
python tests.py |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
from flask import Flask, render_template, json, redirect | ||
|
||
app = Flask(__name__) | ||
|
||
SUPABASE_URL = os.getenv('SUPABASE_URL') | ||
SUPABASE_ANON_KEY = os.getenv('SUPABASE_ANON_KEY') | ||
|
||
@app.route('/') | ||
def home(): | ||
return 'Hello, World!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#from flask_sqlalchemy import SQLAlchemy | ||
from flask import Flask | ||
#from flask_cors import CORS | ||
from supabase import create_client, Client | ||
#from sqlalchemy.orm import sessionmaker | ||
from dotenv import dotenv_values | ||
|
||
def create_app(): | ||
|
||
app = Flask(__name__) | ||
config = dotenv_values("./.env") | ||
url: str = config.get('SUPABASE_URL') | ||
#print("url:",url) | ||
key: str = config.get('SUPABASE_KEY') | ||
#print("key:",key) | ||
supabase: Client = create_client(url, key) | ||
app.config['Client'] = supabase | ||
return app | ||
|
||
|
||
if __name__ == '__main__': | ||
create_app() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from flask import Flask, request, jsonify | ||
from config import create_app | ||
from dotenv import load_dotenv | ||
|
||
app = create_app() | ||
|
||
def test_supabase_connection(): | ||
try: | ||
# Replace 'your_table' with an actual table name to test fetching data | ||
supabase = app.config['Client'] # Ensure this is consistent across your app | ||
data = supabase.table("Users").select("*").execute() | ||
if data: | ||
print("Data fetched successfully:", data.data) | ||
return True, "Database connection was successful." | ||
|
||
print("Failed to fetch data:", data.error_message) | ||
return False, data.error_message | ||
except Exception as e: | ||
print("An error occurred during the database connection:", e) | ||
return False, str(e) | ||
def serialize_user(user): | ||
"""Convert user dictionary to a JSON serializable format.""" | ||
return { | ||
"id": user.get("id"), | ||
"name": user.get("name"), | ||
"email": user.get("email") | ||
# Add more fields as needed based on your database structure | ||
} | ||
|
||
@app.route("/users", methods=['GET','POST']) | ||
def get_users(): | ||
supabase = app.config['Client'] | ||
data = supabase.table("Users").select("*").execute() | ||
users = data.data | ||
# Assuming you have a function to serialize data as JSON | ||
return jsonify([serialize_user(user) for user in users]) | ||
|
||
@app.route("/test", methods=['GET']) | ||
def test(): | ||
success, message = test_supabase_connection() | ||
return jsonify({"success": success, "message": message}) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.