menhguin commited on
Commit
6c0f7f0
1 Parent(s): 71b8ad8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -9,6 +9,12 @@ from elo import update_elo_ratings # Custom function for ELO ratings
9
  enable_btn = gr.Button.update(interactive=True)
10
 
11
  import sqlite3
 
 
 
 
 
 
12
 
13
  from pymongo.mongo_client import MongoClient
14
  from pymongo.server_api import ServerApi
@@ -25,8 +31,9 @@ async def direct_regenerate(model, user_input, chatbot, character_name, characte
25
  password=os.environ.get("MONGODB")
26
 
27
  def init_database():
28
- uri = f"mongodb+srv://minh1228:{password}@cluster0minp.f7ruf.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0MinP"
29
- client = MongoClient(uri)
 
30
  db = client["elo_ratings"]
31
  collection = db["elo_ratings"]
32
  return collection
 
9
  enable_btn = gr.Button.update(interactive=True)
10
 
11
  import sqlite3
12
+ import pymongo
13
+ import urllib
14
+
15
+ mongo_uri = "mongodb://username:" + urllib.parse.quote("p@ssword") + "@127.0.0.1:27001/"
16
+ client = pymongo.MongoClient(mongo_uri)
17
+
18
 
19
  from pymongo.mongo_client import MongoClient
20
  from pymongo.server_api import ServerApi
 
31
  password=os.environ.get("MONGODB")
32
 
33
  def init_database():
34
+ # uri = "mongodb://username:" + urllib.parse.quote("p@ssword") + "@127.0.0.1:27001/"
35
+ uri = "mongodb+srv://minh1228:" + urllib.parse.quote(f"{password}") + "@cluster0minp.f7ruf.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0MinP"
36
+ client = pymongo.MongoClient(uri)
37
  db = client["elo_ratings"]
38
  collection = db["elo_ratings"]
39
  return collection