broadfield commited on
Commit
4e0ecdf
·
verified ·
1 Parent(s): 9268f97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -3,6 +3,7 @@ import io
3
  import os
4
  import uuid
5
  import json
 
6
  import requests
7
  import subprocess
8
  from pypdf import PdfReader
@@ -58,16 +59,16 @@ def save_data(t,m,l,n,w,p):
58
  buffer = io.BytesIO()
59
  buffer.write(file_out.encode())
60
  buffer.seek(0)
61
-
62
  api.upload_file(
63
  path_or_fileobj=buffer,
64
- path_in_repo=f"{title}.html",
65
  repo_id=f'{user_name}/{repo_name}',
66
  token=token,
67
  repo_type="space",
68
  )
69
  #return f"https://broadfield-a.hf.space/?pdfurl={t}&mod={m}&len={l}&nos={n}&wid={w}&pau={p}"
70
- return f"<div><a href='https://broadfield-a.static.hf.space/{title}.html' target='_blank'>https://broadfield-a.static.hf.space/{title}.html</a></div>"
71
  def load_html(url):
72
  html=f"""<iframe src="https://docs.google.com/viewer?url={url})&embedded=true" frameborder="0" height="1200px" width="100%"></iframe></div>"""
73
  return html
 
3
  import os
4
  import uuid
5
  import json
6
+ import random
7
  import requests
8
  import subprocess
9
  from pypdf import PdfReader
 
59
  buffer = io.BytesIO()
60
  buffer.write(file_out.encode())
61
  buffer.seek(0)
62
+ rand = random.randint(1000,9999)
63
  api.upload_file(
64
  path_or_fileobj=buffer,
65
+ path_in_repo=f"{title}-{rand}.html",
66
  repo_id=f'{user_name}/{repo_name}',
67
  token=token,
68
  repo_type="space",
69
  )
70
  #return f"https://broadfield-a.hf.space/?pdfurl={t}&mod={m}&len={l}&nos={n}&wid={w}&pau={p}"
71
+ return f"<div><a href='https://broadfield-a.static.hf.space/{title}-{rand}.html' target='_blank'>https://broadfield-a.static.hf.space/{title}-{rand}.html</a></div>"
72
  def load_html(url):
73
  html=f"""<iframe src="https://docs.google.com/viewer?url={url})&embedded=true" frameborder="0" height="1200px" width="100%"></iframe></div>"""
74
  return html