tejani commited on
Commit
e522daa
·
verified ·
1 Parent(s): f18ad63

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -60,9 +60,7 @@ async def save_file_and_get_url(file: UploadFile) -> str:
60
  logger.error(f"File {file_path} was not saved correctly")
61
  raise HTTPException(status_code=500, detail="Failed to save file")
62
 
63
- # Generate public URL
64
- space_id = os.getenv("SPACE_ID", "tejani-tryapi")
65
- public_url = f"https://{space_id}.hf.space/static/{unique_filename}"
66
  logger.info(f"Generated public URL: {public_url}")
67
 
68
  # Test URL accessibility
@@ -98,7 +96,7 @@ async def try_on(
98
 
99
  headers = {
100
  "accept": "*/*",
101
- "f": "sdfdsfsKaVgUoxa5j1jzcFtziPx",
102
  }
103
 
104
  data = {
@@ -121,8 +119,11 @@ async def try_on(
121
  "garment_url": garment_url
122
  }
123
  except requests.exceptions.RequestException as e:
124
- logger.error(f"Error forwarding request: {unofficial: {str(e)}")
125
  raise HTTPException(status_code=500, detail=f"Error forwarding request: {str(e)}")
 
 
 
126
 
127
  # Health check endpoint
128
  @app.get("/")
 
60
  logger.error(f"File {file_path} was not saved correctly")
61
  raise HTTPException(status_code=500, detail="Failed to save file")
62
 
63
+ public_url = f"https://tejani-tryapi.hf.space/static/{unique_filename}"
 
 
64
  logger.info(f"Generated public URL: {public_url}")
65
 
66
  # Test URL accessibility
 
96
 
97
  headers = {
98
  "accept": "*/*",
99
+ "f": "sdasdwsKaVgUoxa5j1jzcFtziPx",
100
  }
101
 
102
  data = {
 
119
  "garment_url": garment_url
120
  }
121
  except requests.exceptions.RequestException as e:
122
+ logger.error(f"Error forwarding request: {str(e)}")
123
  raise HTTPException(status_code=500, detail=f"Error forwarding request: {str(e)}")
124
+ except Exception as e:
125
+ logger.error(f"Error in try_on endpoint: {str(e)}")
126
+ raise HTTPException(status_code=500, detail=f"Error processing request: {str(e)}")
127
 
128
  # Health check endpoint
129
  @app.get("/")