broadfield commited on
Commit
8571cd0
·
verified ·
1 Parent(s): 797fa06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -7
app.py CHANGED
@@ -8,12 +8,7 @@ from pypdf import PdfReader
8
  from pypipertts import PyPiper
9
  import subprocess
10
  from urllib.parse import urlparse, parse_qs
11
- def get_params(text, request):
12
- print(request)
13
- print(dir(request))
14
- params = request.query_params()
15
- print(params)
16
- get_params("test",gr.Request)
17
  pp=PyPiper()
18
  pp.load_mod()
19
 
@@ -44,7 +39,7 @@ head = """
44
  <meta name="viewport" content="width=device-width" />
45
  <meta name="twitter:card" content="player"/>
46
  <meta name="twitter:site" content=""/>
47
- <meta name="twitter:player" content="https://broadfield-fast-voice-full.hf.space/?pdfurl=ZZZ"/>
48
  <meta name="twitter:player:stream" content="https://broadfield-fast-voice-full.hf.space/?pdfurl=ZZZ"/>
49
  <meta name="twitter:player:width" content="100%"/>
50
  <meta name="twitter:player:height" content="100%"/>
@@ -53,6 +48,28 @@ head = """
53
  <!---meta property="og:image" content=""/--->
54
  <!---meta http-equiv="refresh" content="0; url=https://broadfield-fast-voice-full.hf.space/?pdfurl="--->
55
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  function run(url_in) {
57
  let url = String(url_in)
58
  console.log(url);
@@ -106,6 +123,7 @@ function () {
106
  } else {
107
  p_pau = "1";
108
  };
 
109
  run(p_pdf)
110
  return [p_pdf, p_mod, p_len, p_nos, p_wid, p_pau];
111
  }
 
8
  from pypipertts import PyPiper
9
  import subprocess
10
  from urllib.parse import urlparse, parse_qs
11
+
 
 
 
 
 
12
  pp=PyPiper()
13
  pp.load_mod()
14
 
 
39
  <meta name="viewport" content="width=device-width" />
40
  <meta name="twitter:card" content="player"/>
41
  <meta name="twitter:site" content=""/>
42
+ <meta name="twitter:player" content=""/>
43
  <meta name="twitter:player:stream" content="https://broadfield-fast-voice-full.hf.space/?pdfurl=ZZZ"/>
44
  <meta name="twitter:player:width" content="100%"/>
45
  <meta name="twitter:player:height" content="100%"/>
 
48
  <!---meta property="og:image" content=""/--->
49
  <!---meta http-equiv="refresh" content="0; url=https://broadfield-fast-voice-full.hf.space/?pdfurl="--->
50
  <script>
51
+
52
+
53
+ function changeMetaTag(name, content) {
54
+ // Find the existing meta tag with the given name
55
+ let metaTag = document.querySelector(`meta[name="${name}"]`);
56
+
57
+ // If it doesn't exist, create a new meta tag
58
+ if (!metaTag) {
59
+ metaTag = document.createElement('meta');
60
+ metaTag.name = name;
61
+ document.head.appendChild(metaTag);
62
+ }
63
+
64
+ // Set the content of the meta tag
65
+ metaTag.content = content;
66
+ }
67
+ const urlParams1 = new URLSearchParams(window.location.search);
68
+ var p_pdf = urlParams1.get('pdfurl')
69
+ console.log("params")
70
+ console.log(p_pdf)
71
+ changeMetaTag('twitter:player', 'https://broadfield-fast-voice-full.hf.space/?pdfurl=ZZZ'.replace('ZZZ',p_pdf))
72
+ changeMetaTag('twitter:player:stream', 'https://broadfield-fast-voice-full.hf.space/?pdfurl=ZZZ'.replace('ZZZ',p_pdf))
73
  function run(url_in) {
74
  let url = String(url_in)
75
  console.log(url);
 
123
  } else {
124
  p_pau = "1";
125
  };
126
+
127
  run(p_pdf)
128
  return [p_pdf, p_mod, p_len, p_nos, p_wid, p_pau];
129
  }