h-shibuya commited on
Commit
d50aeb9
1 Parent(s): 4b96787

Update modules/app.py

Browse files
Files changed (1) hide show
  1. modules/app.py +34 -0
modules/app.py CHANGED
@@ -165,6 +165,40 @@ def greet(request: gr.Request):
165
  # return f"Welcome to ∞AI LP, {request.username['name']}", request.username, iframe
166
  return f"Welcome to ∞AI LP, {request.username['name']}", request.username
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
  dev_only = False
169
 
170
  with gr.Blocks(title=meta_title, fill_width=True, css=custom_css, head=gtag) as main_demo:
 
165
  # return f"Welcome to ∞AI LP, {request.username['name']}", request.username, iframe
166
  return f"Welcome to ∞AI LP, {request.username['name']}", request.username
167
 
168
+ def extract_urls(text):
169
+ urls = []
170
+ seen = set()
171
+ i = 0
172
+ n = len(text)
173
+ while i < n:
174
+ if text.startswith('http', i):
175
+ j = i
176
+ while j < n and not text[j].isspace():
177
+ if j != i and text.startswith('http', j):
178
+ # 新しいURLの開始位置を見つけたのでループを抜ける
179
+ break
180
+ j += 1
181
+ url = text[i:j]
182
+ if url not in seen:
183
+ urls.append(url)
184
+ seen.add(url)
185
+ i = j
186
+ else:
187
+ i += 1
188
+ return urls
189
+
190
+ def dummy(url):
191
+ urls = extract_urls(url_text)
192
+ html = ""
193
+ for url in urls:
194
+ print(url)
195
+ html = html + f"""<li>{url}</li>"""
196
+
197
+ html = f"""<ul>{html}</ul>"""
198
+ print(html)
199
+
200
+ return html
201
+
202
  dev_only = False
203
 
204
  with gr.Blocks(title=meta_title, fill_width=True, css=custom_css, head=gtag) as main_demo: