Saqib commited on
Commit
c5714b3
1 Parent(s): 220c52d

Update modules/app.py

Browse files
Files changed (1) hide show
  1. modules/app.py +1 -40
modules/app.py CHANGED
@@ -120,29 +120,6 @@ async def img2location(request: Request):
120
 
121
  if not image_url:
122
  raise HTTPException(status_code=400, detail="image_url not found in request")
123
-
124
- def extract_coordinates(text):
125
- # Split the text into lines
126
- lines = text.split('\n')
127
-
128
- # Iterate through each line to find the one that contains the coordinates
129
- for line in lines:
130
- try:
131
- if line.startswith("Coordinates:"):
132
- # Remove the label and split by comma
133
- coords = line.replace("Coordinates:", "").strip()
134
- lat, lon = coords.split(',')
135
-
136
- # Further split by space to isolate numerical values
137
- latitude = float(lat.split('°')[0].strip())
138
- longitude = float(lon.split('°')[0].strip())
139
-
140
- return latitude, longitude
141
- except Exception as e:
142
- print("Error:", e)
143
- return None
144
- # Return None if no coordinates are found
145
- return None
146
 
147
  headers = {
148
  'accept': '*/*',
@@ -178,23 +155,7 @@ async def img2location(request: Request):
178
  if response.status != 200:
179
  return f"Failed to upload image: HTTP {response.status}"
180
  json_response = await response.json()
181
-
182
- if 'message' in json_response:
183
- json_response['message'] = json_response['message'].strip()
184
- coordinates = extract_coordinates(json_response['message'])
185
-
186
- if coordinates:
187
- latitude, longitude = coordinates
188
- google_maps = f"https://www.google.com/maps/search/?api=1&query={latitude},{longitude}"
189
-
190
- json_response['message'] += f"\n\nView on Google Maps: {google_maps}"
191
-
192
- if img2location_name in json_response['message'].lower():
193
- raise HTTPException(status_code=400, detail="We are not allowed to process this image. Please try another one.")
194
-
195
- return json_response
196
-
197
- raise ValueError(f"Unexpected response: {json_response}")
198
 
199
  @app.post("/pixart-sigma")
200
  async def pixart_sigma(request: Request):
 
120
 
121
  if not image_url:
122
  raise HTTPException(status_code=400, detail="image_url not found in request")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
  headers = {
125
  'accept': '*/*',
 
155
  if response.status != 200:
156
  return f"Failed to upload image: HTTP {response.status}"
157
  json_response = await response.json()
158
+ return json_response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
  @app.post("/pixart-sigma")
161
  async def pixart_sigma(request: Request):