freegpu commited on
Commit
db79667
·
verified ·
1 Parent(s): 1e8c18a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -2
app.py CHANGED
@@ -320,11 +320,36 @@ def run_prediction_for_gradio(limit, tsym, crypto_name, timeframe):
320
 
321
  # 2. Add 2 hours using timedelta
322
  future_date = now + timedelta(hours=2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  # 1. Send PENDING status
324
 
325
  # Call the train_full function to get predictions
326
  predicted_values = train_full(limit, tsym, crypto_name, timeframe)
327
-
328
  # Initialize output_str before potential use in except block
329
  output_str = ""
330
  # finally inserting the actual data over the network
@@ -332,7 +357,7 @@ def run_prediction_for_gradio(limit, tsym, crypto_name, timeframe):
332
  # 1. Send TRAINED status
333
  trained_url = f"{BASE_API_URL}insert-trained/"
334
  trained_data = {
335
- "pendingId": pending_resp.json().get("id"),
336
  "secret": SECRET_CODE,
337
  "crypto_name": crypto_name,
338
  "timeframe": timeframe,
 
320
 
321
  # 2. Add 2 hours using timedelta
322
  future_date = now + timedelta(hours=2)
323
+ data_to_send = {
324
+ "timeframe": timeframe,
325
+ "crypto_name": crypto_name,
326
+ "tysm": tysm,
327
+ }
328
+
329
+ # 2. Define the target URL
330
+ url = f"{BASE_API_URL}/endpoint/training/response-for-huggingface/"
331
+
332
+ try:
333
+ # 3. Perform the POST request
334
+ # Using 'json=' automatically sets Content-Type to application/json
335
+ response = requests.post(url, json=data_to_send)
336
+
337
+ # 4. Handle the response
338
+ response.raise_for_status() # Check for HTTP errors (4xx or 5xx)
339
+
340
+ # Process the data (assuming the server returns JSON)
341
+ result = response.json()
342
+ print("Success! Response data:", result)
343
+
344
+ except requests.exceptions.HTTPError as err:
345
+ print(f"HTTP error occurred: {err}")
346
+ except Exception as err:
347
+ print(f"An error occurred: {err}")
348
  # 1. Send PENDING status
349
 
350
  # Call the train_full function to get predictions
351
  predicted_values = train_full(limit, tsym, crypto_name, timeframe)
352
+
353
  # Initialize output_str before potential use in except block
354
  output_str = ""
355
  # finally inserting the actual data over the network
 
357
  # 1. Send TRAINED status
358
  trained_url = f"{BASE_API_URL}insert-trained/"
359
  trained_data = {
360
+ "pendingId": result.json().get("id"),
361
  "secret": SECRET_CODE,
362
  "crypto_name": crypto_name,
363
  "timeframe": timeframe,