Dede16 commited on
Commit
8557113
·
1 Parent(s): 0cdd62c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -20,6 +20,7 @@ import datetime
20
  import pytz
21
  import csv
22
  import cv2
 
23
  from io import StringIO
24
  from huggingface_hub import (
25
  create_repo,
@@ -439,13 +440,18 @@ def scrap(link_scrap,backlink,keyword,openai_key,replicate_key):
439
  with open('log_activity.txt', 'r') as file:
440
  existing_data = file.read()
441
 
442
- log = 'Generated_Title:'+judul+'\nTimestamp:'+Timestamp + '\n'
443
-
444
  combined_data = existing_data + log
445
-
 
 
 
 
 
446
  repo_name = get_full_repo_name(model_id="Article_Gen2", token="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")
447
  file_url = upload_file(
448
- path_or_fileobj=combined_data,
449
  path_in_repo="log_activity.txt",
450
  repo_id=repo_name,
451
  repo_type="space",
 
20
  import pytz
21
  import csv
22
  import cv2
23
+ import tempfile
24
  from io import StringIO
25
  from huggingface_hub import (
26
  create_repo,
 
440
  with open('log_activity.txt', 'r') as file:
441
  existing_data = file.read()
442
 
443
+ log = 'Generated_Title:' + judul + '\nTimestamp:' + Timestamp + '\n'
444
+
445
  combined_data = existing_data + log
446
+
447
+ # Create a temporary file and write the combined_data to it
448
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
449
+ temp_file.write(combined_data)
450
+
451
+ # Upload the temporary file
452
  repo_name = get_full_repo_name(model_id="Article_Gen2", token="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")
453
  file_url = upload_file(
454
+ path_or_fileobj=temp_file.name, # Use the temporary file name
455
  path_in_repo="log_activity.txt",
456
  repo_id=repo_name,
457
  repo_type="space",