Spaces:
Sleeping
Sleeping
Abdelkareem
commited on
deploy at 2024-12-22 23:36:10.283855
Browse files- config.ini +6 -0
- food_sql.py +9 -9
- main.py +28 -0
config.ini
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[DEFAULT]
|
2 |
+
dataset_id = space-backup
|
3 |
+
db_dir = data
|
4 |
+
private_backup = True
|
5 |
+
interval = 15
|
6 |
+
|
food_sql.py
CHANGED
@@ -57,13 +57,13 @@ except Exception as e:
|
|
57 |
items = foods()
|
58 |
print(len(items))
|
59 |
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
57 |
items = foods()
|
58 |
print(len(items))
|
59 |
|
60 |
+
for item in items[:5]:
|
61 |
+
print(item.arabic_name, item.name, item.calories)
|
62 |
|
63 |
+
el = foods.search("banana")
|
64 |
+
for e in el:
|
65 |
+
print(e["name"])
|
66 |
+
print(e["arabic_name"])
|
67 |
+
print(e["calories"])
|
68 |
+
print(e)
|
69 |
+
break
|
main.py
CHANGED
@@ -1,7 +1,34 @@
|
|
1 |
from fasthtml.common import *
|
2 |
from faq import create_faq
|
|
|
3 |
from fasthtml_hf import setup_hf_backup
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
seo_meta = [
|
6 |
Meta(
|
7 |
name="description",
|
@@ -208,6 +235,7 @@ def get():
|
|
208 |
),
|
209 |
)
|
210 |
|
|
|
211 |
setup_hf_backup(app)
|
212 |
|
213 |
if __name__ == "__main__":
|
|
|
1 |
from fasthtml.common import *
|
2 |
from faq import create_faq
|
3 |
+
import pandas as pd
|
4 |
from fasthtml_hf import setup_hf_backup
|
5 |
|
6 |
+
df = pd.read_csv("./ar_en_nutrition.csv")
|
7 |
+
from food_sql import create_food_model, update_database
|
8 |
+
|
9 |
+
app, rt, foods, Food = create_food_model(df)
|
10 |
+
|
11 |
+
try:
|
12 |
+
app, rt, foods, Food = create_food_model(df)
|
13 |
+
update_database(df)
|
14 |
+
print("Database updated successfully!")
|
15 |
+
except Exception as e:
|
16 |
+
print(f"Error updating database: {e}")
|
17 |
+
|
18 |
+
items = foods()
|
19 |
+
print(len(items))
|
20 |
+
|
21 |
+
for item in items[:5]:
|
22 |
+
print(item.arabic_name, item.name, item.calories)
|
23 |
+
|
24 |
+
el = foods.search("banana")
|
25 |
+
for e in el:
|
26 |
+
print(e["name"])
|
27 |
+
print(e["arabic_name"])
|
28 |
+
print(e["calories"])
|
29 |
+
print(e)
|
30 |
+
break
|
31 |
+
|
32 |
seo_meta = [
|
33 |
Meta(
|
34 |
name="description",
|
|
|
235 |
),
|
236 |
)
|
237 |
|
238 |
+
|
239 |
setup_hf_backup(app)
|
240 |
|
241 |
if __name__ == "__main__":
|