root-sajjan
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -103,6 +103,23 @@ async def login(user_data: UserLogin):
|
|
103 |
except Exception as e:
|
104 |
raise HTTPException(status_code=500, detail=str(e))
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
@app.post("/upload")
|
108 |
async def upload_image(image: UploadFile = File(...)):
|
|
|
103 |
except Exception as e:
|
104 |
raise HTTPException(status_code=500, detail=str(e))
|
105 |
|
106 |
+
@app.get("/users")
|
107 |
+
async def get_users():
|
108 |
+
try:
|
109 |
+
conn = sqlite3.connect('users.db')
|
110 |
+
conn.row_factory = sqlite3.Row # This makes rows behave like dictionaries
|
111 |
+
c = conn.cursor()
|
112 |
+
|
113 |
+
c.execute("SELECT * FROM users")
|
114 |
+
rows = c.fetchall()
|
115 |
+
conn.close()
|
116 |
+
|
117 |
+
# Convert rows to a list of dictionaries
|
118 |
+
users = [dict(row) for row in rows]
|
119 |
+
return users
|
120 |
+
except Exception as e:
|
121 |
+
raise HTTPException(status_code=500, detail=str(e))
|
122 |
+
|
123 |
|
124 |
@app.post("/upload")
|
125 |
async def upload_image(image: UploadFile = File(...)):
|