Spaces:
Sleeping
Sleeping
Commit
·
59062aa
1
Parent(s):
6a1b0dd
status changes made
Browse files- App/app.py +42 -3
- App/scheduler.py +3 -1
App/app.py
CHANGED
|
@@ -17,8 +17,8 @@ from io import BytesIO
|
|
| 17 |
import threading
|
| 18 |
from datetime import timedelta
|
| 19 |
import json
|
| 20 |
-
|
| 21 |
-
|
| 22 |
warnings.filterwarnings("ignore", message=".*QuickGELU mismatch.*")
|
| 23 |
|
| 24 |
|
|
@@ -162,17 +162,22 @@ def login():
|
|
| 162 |
|
| 163 |
|
| 164 |
@app.route('/logout',methods=["GET"])
|
| 165 |
-
|
|
|
|
| 166 |
res=make_response({
|
| 167 |
"success":True,
|
| 168 |
"message":"Logout Successfully"
|
| 169 |
})
|
| 170 |
unset_jwt_cookies(res)
|
|
|
|
|
|
|
| 171 |
return res,200
|
| 172 |
|
|
|
|
| 173 |
@app.route('/get_user',methods=['GET'])
|
| 174 |
@decode_jwt
|
| 175 |
def get_user(user_id):
|
|
|
|
| 176 |
user=user= db.table("users").select("*").eq("id",user_id).limit(1).execute().data[0]
|
| 177 |
return jsonify({
|
| 178 |
"success":True,
|
|
@@ -450,6 +455,40 @@ def foundMatchDetail(lost_id):
|
|
| 450 |
"success":True,
|
| 451 |
"foundItems": found_items
|
| 452 |
}),200
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
|
| 454 |
if __name__ == "__main__":
|
| 455 |
app.run(
|
|
|
|
| 17 |
import threading
|
| 18 |
from datetime import timedelta
|
| 19 |
import json
|
| 20 |
+
from dotenv import load_dotenv
|
| 21 |
+
load_dotenv()
|
| 22 |
warnings.filterwarnings("ignore", message=".*QuickGELU mismatch.*")
|
| 23 |
|
| 24 |
|
|
|
|
| 162 |
|
| 163 |
|
| 164 |
@app.route('/logout',methods=["GET"])
|
| 165 |
+
@decode_jwt
|
| 166 |
+
def logout(user_id):
|
| 167 |
res=make_response({
|
| 168 |
"success":True,
|
| 169 |
"message":"Logout Successfully"
|
| 170 |
})
|
| 171 |
unset_jwt_cookies(res)
|
| 172 |
+
res.set_cookie("Token","",httponly=True,secure=True,samesite="None",max_age=259200,domain=".localhost")
|
| 173 |
+
|
| 174 |
return res,200
|
| 175 |
|
| 176 |
+
|
| 177 |
@app.route('/get_user',methods=['GET'])
|
| 178 |
@decode_jwt
|
| 179 |
def get_user(user_id):
|
| 180 |
+
print(user_id)
|
| 181 |
user=user= db.table("users").select("*").eq("id",user_id).limit(1).execute().data[0]
|
| 182 |
return jsonify({
|
| 183 |
"success":True,
|
|
|
|
| 455 |
"success":True,
|
| 456 |
"foundItems": found_items
|
| 457 |
}),200
|
| 458 |
+
|
| 459 |
+
@app.route('/setFound/<lost_id>/<found_id>',methods=['GET'])
|
| 460 |
+
@decode_jwt
|
| 461 |
+
def setFound(lost_id,found_id,user_id):
|
| 462 |
+
lost_item=db.table("lostItem").select("*").eq("id",lost_id).limit(1).execute().data[0]
|
| 463 |
+
found_item=db.table("foundItem").select("*").eq("id",found_id).limit(1).execute().data[0]
|
| 464 |
+
if not lost_item or not found_item:
|
| 465 |
+
return jsonify({
|
| 466 |
+
"success":False,
|
| 467 |
+
"message":"No Item Found"
|
| 468 |
+
}),400
|
| 469 |
+
db.table("lostItem").update({"status":"matched"}).eq("id",lost_id).execute()
|
| 470 |
+
db.table("foundItem").update({"status":"matched"}).eq("id",found_id).execute()
|
| 471 |
+
return jsonify({
|
| 472 |
+
"success":True,
|
| 473 |
+
"message":"Match Set Successfully"
|
| 474 |
+
}),200
|
| 475 |
+
|
| 476 |
+
@app.route('/setNotFound/<lost_id>/<found_id>',methods=['GET'])
|
| 477 |
+
@decode_jwt
|
| 478 |
+
def setNotFound(lost_id,found_id,user_id):
|
| 479 |
+
lost_item=db.table("lostItem").select("*").eq("id",lost_id).limit(1).execute().data[0]
|
| 480 |
+
found_item=db.table("foundItem").select("*").eq("id",found_id).limit(1).execute().data[0]
|
| 481 |
+
if not lost_item or not found_item:
|
| 482 |
+
return jsonify({
|
| 483 |
+
"success":False,
|
| 484 |
+
"message":"No Item Found"
|
| 485 |
+
}),400
|
| 486 |
+
db.table("lostItem").update({"status":"active"}).eq("id",lost_id).execute()
|
| 487 |
+
db.table("foundItem").update({"status":"active"}).eq("id",found_id).execute()
|
| 488 |
+
return jsonify({
|
| 489 |
+
"success":True,
|
| 490 |
+
"message":"Match Set Successfully"
|
| 491 |
+
}),200
|
| 492 |
|
| 493 |
if __name__ == "__main__":
|
| 494 |
app.run(
|
App/scheduler.py
CHANGED
|
@@ -90,7 +90,9 @@ def match_active_lost():
|
|
| 90 |
results = qdrant.search(
|
| 91 |
collection_name="found_items",
|
| 92 |
query_vector=lost_vector,
|
| 93 |
-
limit=top_k,
|
|
|
|
|
|
|
| 94 |
query_filter=qfilter
|
| 95 |
)
|
| 96 |
except Exception as e:
|
|
|
|
| 90 |
results = qdrant.search(
|
| 91 |
collection_name="found_items",
|
| 92 |
query_vector=lost_vector,
|
| 93 |
+
limit=top_k,
|
| 94 |
+
with_payload=True,
|
| 95 |
+
with_vectors=False,
|
| 96 |
query_filter=qfilter
|
| 97 |
)
|
| 98 |
except Exception as e:
|