Spaces:
Runtime error
Runtime error
Commit
·
6ca6733
1
Parent(s):
0e1d8b9
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,13 +70,28 @@ except sqlite3.OperationalError:
|
|
| 70 |
db.close()
|
| 71 |
|
| 72 |
db = sqlite3.connect(DB_FILE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
def
|
| 75 |
reviews = db.execute("SELECT * FROM reviews ORDER BY id DESC limit 100").fetchall()
|
| 76 |
total_reviews = db.execute("Select COUNT(id) from reviews").fetchone()[0]
|
| 77 |
reviews = pd.DataFrame(reviews, columns=["id", "date_created", "name", "rate", "celsci"])
|
| 78 |
return reviews, total_reviews
|
| 79 |
|
|
|
|
| 80 |
def get_latest_reviews2(db: sqlite3.Connection):
|
| 81 |
reviews2 = db.execute("SELECT * FROM reviews2 ORDER BY id DESC limit 100").fetchall()
|
| 82 |
total_reviews2 = db.execute("Select COUNT(id) from reviews2").fetchone()[0]
|
|
@@ -104,6 +119,29 @@ def ccogsphere(name: str, rate: int, celsci: str):
|
|
| 104 |
r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [name,celsci]})
|
| 105 |
#demo.load()
|
| 106 |
return reviews, total_reviews
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
def run_actr():
|
| 109 |
from python_actr import log_everything
|
|
@@ -135,10 +173,10 @@ def run_ecs(inp):
|
|
| 135 |
db = sqlite3.connect(DB_FILE)
|
| 136 |
#cursor = db.cursor()
|
| 137 |
#cursor.execute("INSERT INTO reviews2(title, link, thumbnail,channel, description, views, uploaded, duration, durationString) VALUES(?,?,?,?,?,?,?,?,?)", [title, link, thumbnail,channel, description, views, uploaded, duration, durationString])
|
| 138 |
-
df.to_sql('reviews2', db, if_exists='
|
| 139 |
|
| 140 |
#db.commit()
|
| 141 |
-
reviews2, total_reviews2 =
|
| 142 |
db.close()
|
| 143 |
#print ("print000", total_reviews2,reviews2)
|
| 144 |
return reviews2, total_reviews2
|
|
@@ -170,16 +208,16 @@ with gr.Blocks(css=css) as demo:
|
|
| 170 |
celsci = gr.Textbox(label="c") #, lines=10, placeholder="Do you have any feedback on gradio?")
|
| 171 |
#run_actr()
|
| 172 |
submit = gr.Button(value=".")
|
| 173 |
-
submit.click(
|
| 174 |
demo.load(load_data, None, [data, count])
|
| 175 |
-
|
| 176 |
@rate.change(inputs=rate, outputs=name,_js="window.location.reload()")
|
| 177 |
-
|
| 178 |
|
| 179 |
def secwork(name):
|
| 180 |
#if name=="abc":
|
| 181 |
#run_code()
|
| 182 |
-
|
| 183 |
#return "Hello " + name + "!"
|
| 184 |
def backup_db():
|
| 185 |
shutil.copyfile(DB_FILE, "./reviews.db")
|
|
|
|
| 70 |
db.close()
|
| 71 |
|
| 72 |
db = sqlite3.connect(DB_FILE)
|
| 73 |
+
################db tabl2
|
| 74 |
+
|
| 75 |
+
try:
|
| 76 |
+
db.execute("SELECT * FROM reviews2").fetchall()
|
| 77 |
+
#db.execute("SELECT * FROM reviews2").fetchall()
|
| 78 |
+
|
| 79 |
+
db.close()
|
| 80 |
+
except sqlite3.OperationalError:
|
| 81 |
+
db.execute(
|
| 82 |
+
'''
|
| 83 |
+
CREATE TABLE reviews2 (id TEXT, title TEXT, link TEXT,channel TEXT, description TEXT, views INTEGER, uploaded TEXT, duration INTEGER, durationString TEXT)
|
| 84 |
+
''')
|
| 85 |
+
db.commit()
|
| 86 |
+
db.close()
|
| 87 |
|
| 88 |
+
def get_latest_reviews11(db: sqlite3.Connection):
|
| 89 |
reviews = db.execute("SELECT * FROM reviews ORDER BY id DESC limit 100").fetchall()
|
| 90 |
total_reviews = db.execute("Select COUNT(id) from reviews").fetchone()[0]
|
| 91 |
reviews = pd.DataFrame(reviews, columns=["id", "date_created", "name", "rate", "celsci"])
|
| 92 |
return reviews, total_reviews
|
| 93 |
|
| 94 |
+
|
| 95 |
def get_latest_reviews2(db: sqlite3.Connection):
|
| 96 |
reviews2 = db.execute("SELECT * FROM reviews2 ORDER BY id DESC limit 100").fetchall()
|
| 97 |
total_reviews2 = db.execute("Select COUNT(id) from reviews2").fetchone()[0]
|
|
|
|
| 119 |
r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [name,celsci]})
|
| 120 |
#demo.load()
|
| 121 |
return reviews, total_reviews
|
| 122 |
+
|
| 123 |
+
def ccogsphere11(name: str, rate: int, celsci: str):
|
| 124 |
+
db = sqlite3.connect(DB_FILE)
|
| 125 |
+
cursor = db.cursor()
|
| 126 |
+
|
| 127 |
+
try:
|
| 128 |
+
celsci2=celsci.split()
|
| 129 |
+
print("split",celsci2,celsci)
|
| 130 |
+
celsci2=celsci2[0] + "+" + celsci2[1]
|
| 131 |
+
celsci2=ecf(celsci2)
|
| 132 |
+
celsci2=json.dumps(celsci2["videos"])
|
| 133 |
+
except:
|
| 134 |
+
celsci2=" No Info Found"
|
| 135 |
+
|
| 136 |
+
celsci=celsci+celsci2
|
| 137 |
+
cursor.execute("INSERT INTO reviews(name, rate, celsci) VALUES(?,?,?)", [name, rate, celsci])
|
| 138 |
+
db.commit()
|
| 139 |
+
reviews, total_reviews = get_latest_reviews(db)
|
| 140 |
+
db.close()
|
| 141 |
+
r = requests.post(url='https://ccml-persistent-data2.hf.space/api/predict/', json={"data": [name,celsci]})
|
| 142 |
+
#demo.load()
|
| 143 |
+
return reviews, total_reviews
|
| 144 |
+
|
| 145 |
|
| 146 |
def run_actr():
|
| 147 |
from python_actr import log_everything
|
|
|
|
| 173 |
db = sqlite3.connect(DB_FILE)
|
| 174 |
#cursor = db.cursor()
|
| 175 |
#cursor.execute("INSERT INTO reviews2(title, link, thumbnail,channel, description, views, uploaded, duration, durationString) VALUES(?,?,?,?,?,?,?,?,?)", [title, link, thumbnail,channel, description, views, uploaded, duration, durationString])
|
| 176 |
+
df.to_sql('reviews2', db, if_exists='append', index=False)
|
| 177 |
|
| 178 |
#db.commit()
|
| 179 |
+
reviews2, total_reviews2 = get_latest_reviews2(db)
|
| 180 |
db.close()
|
| 181 |
#print ("print000", total_reviews2,reviews2)
|
| 182 |
return reviews2, total_reviews2
|
|
|
|
| 208 |
celsci = gr.Textbox(label="c") #, lines=10, placeholder="Do you have any feedback on gradio?")
|
| 209 |
#run_actr()
|
| 210 |
submit = gr.Button(value=".")
|
| 211 |
+
submit.click(run_ecs, [name, rate, celsci], [data, count])
|
| 212 |
demo.load(load_data, None, [data, count])
|
| 213 |
+
#@name.change(inputs=name, outputs=celsci,_js="window.location.reload()")
|
| 214 |
@rate.change(inputs=rate, outputs=name,_js="window.location.reload()")
|
| 215 |
+
#@celsci.change(inputs=celsci, outputs=rate,_js="window.location.reload()")
|
| 216 |
|
| 217 |
def secwork(name):
|
| 218 |
#if name=="abc":
|
| 219 |
#run_code()
|
| 220 |
+
load_data2()
|
| 221 |
#return "Hello " + name + "!"
|
| 222 |
def backup_db():
|
| 223 |
shutil.copyfile(DB_FILE, "./reviews.db")
|