broadfield commited on
Commit
0da0e15
·
verified ·
1 Parent(s): 2fdecd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -53,28 +53,30 @@ def load_data(file):
53
  return(lod)
54
 
55
  def save_data(t,m,l,n,w,p):
 
 
56
  title = t.replace('https://',"").replace('/',"_").replace('.',"_")
57
  im = mi.run_1(name=title,img_size=[256,256])
58
- im2=f"https://broadfield-a.static.hf.space/file={title}.png"
59
  #uid=uuid.uuid4()
60
  with open('template.html','r') as file:
61
  file_cont=file.read()
62
  file.close()
63
  file_out=file_cont.replace('IMAGE',im2).replace('TITLE',title).replace('PDFURL',t).replace('VOICE',m).replace('LENGTH',l).replace('NOISE',n).replace('WIDTH',w).replace('PAUSE',p)
 
64
  buffer = io.BytesIO()
65
  buffer.write(file_out.encode())
66
  buffer.seek(0)
67
- rand = random.randint(1000,9999)
68
  api.upload_file(
69
  path_or_fileobj=buffer,
70
- path_in_repo=f"{title}_{rand}.html",
71
  repo_id=f'{user_name}/{repo_name}',
72
  token=token,
73
  repo_type="space",
74
  )
75
  api.upload_file(
76
  path_or_fileobj=im2,
77
- path_in_repo=f"/images/{title}.png",
78
  repo_id=f'{user_name}/{repo_name}',
79
  token=token,
80
  repo_type="space",
 
53
  return(lod)
54
 
55
  def save_data(t,m,l,n,w,p):
56
+ rand = random.randint(1000,9999)
57
+
58
  title = t.replace('https://',"").replace('/',"_").replace('.',"_")
59
  im = mi.run_1(name=title,img_size=[256,256])
60
+ im2=f"https://{user_name}-{repo_name}.static.hf.space/file=images{title}.png"
61
  #uid=uuid.uuid4()
62
  with open('template.html','r') as file:
63
  file_cont=file.read()
64
  file.close()
65
  file_out=file_cont.replace('IMAGE',im2).replace('TITLE',title).replace('PDFURL',t).replace('VOICE',m).replace('LENGTH',l).replace('NOISE',n).replace('WIDTH',w).replace('PAUSE',p)
66
+ out_name=f"{title}_{rand}"
67
  buffer = io.BytesIO()
68
  buffer.write(file_out.encode())
69
  buffer.seek(0)
 
70
  api.upload_file(
71
  path_or_fileobj=buffer,
72
+ path_in_repo=f"{out_name}.html",
73
  repo_id=f'{user_name}/{repo_name}',
74
  token=token,
75
  repo_type="space",
76
  )
77
  api.upload_file(
78
  path_or_fileobj=im2,
79
+ path_in_repo=f"/images/{out_name}.png",
80
  repo_id=f'{user_name}/{repo_name}',
81
  token=token,
82
  repo_type="space",