Dede16 commited on
Commit
05a012e
·
1 Parent(s): 8a5aafd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -46
app.py CHANGED
@@ -523,52 +523,26 @@ def scrap(source_type,source,backlink,keyword,version,api_key,azure_api_base,rep
523
  repo_type="space",
524
  token="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",
525
  )
526
- if len(kontent)>=1200:
527
- with open('log_activity.txt', 'r') as file:
528
- existing_data = file.read()
529
-
530
- log = url + "\n"
531
-
532
- combined_data = existing_data + log
533
-
534
- with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
535
- temp_file.write(combined_data)
536
-
537
- repo_name = get_full_repo_name(model_id="Article_Gen4", token="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")
538
- file_url = upload_file(
539
- path_or_fileobj=temp_file.name,
540
- path_in_repo="log_activity.txt",
541
- repo_id=repo_name,
542
- repo_type="space",
543
- token="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",
544
- )
545
- status = "<h3>Berhasil Generate Artikel</h3>"
546
- time.sleep(60)
547
- return status,gambar
548
-
549
- else:
550
- with open('log_activity.txt', 'r') as file:
551
- existing_data = file.read()
552
-
553
- log = url + "\n"
554
-
555
- combined_data = existing_data + log
556
-
557
- with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
558
- temp_file.write(combined_data)
559
-
560
-
561
- repo_name = get_full_repo_name(model_id="Article_Gen4", token="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")
562
- file_url = upload_file(
563
- path_or_fileobj=temp_file.name,
564
- path_in_repo="log_activity.txt",
565
- repo_id=repo_name,
566
- repo_type="space",
567
- token="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",
568
- )
569
- status = "<h3>Gagal Generate Artikel, Coba Generate Ulang atau Ganti Input Source</h3>"
570
- gambar = Image.open("error.png")
571
- return status,gambar
572
  # except:
573
  # status = "<h3>Gagal Generate Artikel</h3>"
574
  # gambar = Image.open('error.png')
 
523
  repo_type="space",
524
  token="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",
525
  )
526
+ with open('log_activity.txt', 'r') as file:
527
+ existing_data = file.read()
528
+
529
+ log = url + "\n"
530
+
531
+ combined_data = existing_data + log
532
+
533
+ with tempfile.NamedTemporaryFile(mode='w', delete=False) as temp_file:
534
+ temp_file.write(combined_data)
535
+
536
+ file_url = upload_file(
537
+ path_or_fileobj=temp_file.name,
538
+ path_in_repo="log_activity.txt",
539
+ repo_id=repo_name,
540
+ repo_type="space",
541
+ token="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",
542
+ )
543
+ status = "<h3>Berhasil Generate Artikel</h3>"
544
+ time.sleep(60)
545
+ return status,gambar
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  # except:
547
  # status = "<h3>Gagal Generate Artikel</h3>"
548
  # gambar = Image.open('error.png')