Arcader7171 commited on
Commit
338a575
·
verified ·
1 Parent(s): 830fb2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -11,7 +11,8 @@ import jwt
11
  app = Flask(__name__)
12
  app.config['SECRET_KEY'] = os.environ.get("FLASK_KEY")
13
  url: str = os.environ.get("SUPABASE_URL")
14
- key: str = os.environ.get("SUPABASE_SERVICE_KEY")
 
15
  jwtKey: str = os.environ.get("JWTKey")
16
 
17
  # Function Config
@@ -43,7 +44,7 @@ def signup():
43
  async def login():
44
  error = None
45
  if request.method == 'POST':
46
- supabase: AsyncClient = await acreate_client(url, key)
47
  inData = request.form # input data, to seperate from the real, valid data
48
  inUser = inData["user"]
49
  inPass = inData["pass"]
@@ -94,7 +95,7 @@ async def signupAPI():
94
 
95
  @app.post("/api/message")
96
  async def messageAPI():
97
- supabase: AsyncClient = await acreate_client(url, key)
98
  if request.method == 'POST':
99
  data = json.loads(request.data)
100
  msg = data["msg"]
@@ -121,7 +122,7 @@ async def interApp():
121
  if "password" not in session:
122
  wipeSession()
123
  return redirect(url_for("login"))
124
- supabase: AsyncClient = await acreate_client(url, key)
125
  response = (
126
  await supabase.table("messages")
127
  .select("author_name, content")
@@ -135,4 +136,8 @@ async def interApp():
135
  if msg["author_name"] == session["username"]:
136
  local = True
137
  msgHistory.append({"user": msg["author_name"], "message": msg["content"], "local": local})
138
- return render_template("app.html", history=msgHistory)
 
 
 
 
 
11
  app = Flask(__name__)
12
  app.config['SECRET_KEY'] = os.environ.get("FLASK_KEY")
13
  url: str = os.environ.get("SUPABASE_URL")
14
+ publicKey: str = os.environ.get("SUPABASE_PUBLIC_KEY")
15
+ serviceKey: str = os.environ.get("SUPABASE_SERVICE_KEY")
16
  jwtKey: str = os.environ.get("JWTKey")
17
 
18
  # Function Config
 
44
  async def login():
45
  error = None
46
  if request.method == 'POST':
47
+ supabase: AsyncClient = await acreate_client(url, serviceKey)
48
  inData = request.form # input data, to seperate from the real, valid data
49
  inUser = inData["user"]
50
  inPass = inData["pass"]
 
95
 
96
  @app.post("/api/message")
97
  async def messageAPI():
98
+ supabase: AsyncClient = await acreate_client(url, serviceKey)
99
  if request.method == 'POST':
100
  data = json.loads(request.data)
101
  msg = data["msg"]
 
122
  if "password" not in session:
123
  wipeSession()
124
  return redirect(url_for("login"))
125
+ supabase: AsyncClient = await acreate_client(url, serviceKey)
126
  response = (
127
  await supabase.table("messages")
128
  .select("author_name, content")
 
136
  if msg["author_name"] == session["username"]:
137
  local = True
138
  msgHistory.append({"user": msg["author_name"], "message": msg["content"], "local": local})
139
+ supa = {
140
+ "url": url,
141
+ "key": publicKey
142
+ }
143
+ return render_template("app.html", history=msgHistory, supa=supa)