m8chaa commited on
Commit
19056cf
·
verified ·
1 Parent(s): bcb46aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -18
app.py CHANGED
@@ -893,27 +893,12 @@ async def sync_data(data_json: str = Form(...), user_id: str = Form(...)):
893
  raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(e)}")
894
 
895
 
896
-
897
-
898
- def get_file(service, file_id):
899
- try:
900
- file = service.files().get(fileId=file_id).execute()
901
- print('Found file: %s (%s)' % (file.get('name'), file.get('id')))
902
- return file
903
- except Exception as e:
904
- print('An error occurred:', e)
905
- return None
906
- def get_user_info(service):
907
- about = service.about().get(fields='user').execute()
908
- print('User info:', about['user'])
909
-
910
-
911
  # Function to watch a Google Drive folder
912
  def create_channel(service, folder_id):
913
  body = {
914
  'id': 'unique-channel-id',
915
  'type': 'web_hook',
916
- 'address': 'https://m8chaa-re-sheet-develop.hf.space/notifications', # Replace with your webhook URL
917
  }
918
  response = service.files().watch(fileId=folder_id, body=body).execute()
919
  return response
@@ -921,8 +906,6 @@ def create_channel(service, folder_id):
921
  @app.post("/watch/{folder_id}")
922
  async def watch_folder_endpoint(folder_id: str):
923
  try:
924
- get_user_info(drive_service)
925
- get_file(drive_service, folder_id)
926
  # Create a channel to watch the folder
927
  response = create_channel(drive_service, folder_id)
928
 
 
893
  raise HTTPException(status_code=500, detail=f"An unexpected error occurred: {str(e)}")
894
 
895
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
896
  # Function to watch a Google Drive folder
897
  def create_channel(service, folder_id):
898
  body = {
899
  'id': 'unique-channel-id',
900
  'type': 'web_hook',
901
+ 'address': 'https://m8chaa-re-sheet-develop.hf.space/notifications',
902
  }
903
  response = service.files().watch(fileId=folder_id, body=body).execute()
904
  return response
 
906
  @app.post("/watch/{folder_id}")
907
  async def watch_folder_endpoint(folder_id: str):
908
  try:
 
 
909
  # Create a channel to watch the folder
910
  response = create_channel(drive_service, folder_id)
911