akhaliq HF Staff commited on
Commit
dc45753
·
1 Parent(s): dab9e04
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -235,7 +235,7 @@ def create_space_from_html(title: str, html_content: str, prompts: List[str] = N
235
  )
236
 
237
  # Prepare the HTML content with proper structure
238
- full_html = f"""<!DOCTYPE html>
239
  <html lang="en">
240
  <head>
241
  <meta charset="UTF-8">
@@ -299,6 +299,8 @@ def create_space_from_html(title: str, html_content: str, prompts: List[str] = N
299
  </body>
300
  </html>"""
301
 
 
 
302
  # Upload the HTML file
303
  user_hf_api.upload_file(
304
  path_or_fileobj=full_html.encode('utf-8'),
@@ -308,7 +310,8 @@ def create_space_from_html(title: str, html_content: str, prompts: List[str] = N
308
  )
309
 
310
  # Create README.md with project info
311
- readme_content = f"""# {title}
 
312
 
313
  This project was generated using [AnyCoder](https://huggingface.co/spaces/ahsenkhaliq/anycoder), an AI-powered code generator.
314
 
@@ -318,7 +321,7 @@ This is a static HTML application created by describing the requirements in plai
318
 
319
  ## Generated Prompts
320
 
321
- {f"".join([f"- {prompt}\n" for prompt in (prompts or [])])}
322
 
323
  ## View Live
324
 
@@ -328,6 +331,8 @@ Visit: https://huggingface.co/spaces/{repo_name}
328
  *Generated with ❤️ using AnyCoder*
329
  """
330
 
 
 
331
  user_hf_api.upload_file(
332
  path_or_fileobj=readme_content.encode('utf-8'),
333
  path_in_repo="README.md",
 
235
  )
236
 
237
  # Prepare the HTML content with proper structure
238
+ html_template = """<!DOCTYPE html>
239
  <html lang="en">
240
  <head>
241
  <meta charset="UTF-8">
 
299
  </body>
300
  </html>"""
301
 
302
+ full_html = html_template.format(title=title, html_content=html_content)
303
+
304
  # Upload the HTML file
305
  user_hf_api.upload_file(
306
  path_or_fileobj=full_html.encode('utf-8'),
 
310
  )
311
 
312
  # Create README.md with project info
313
+ prompts_text = "".join([f"- {prompt}\n" for prompt in (prompts or [])])
314
+ readme_template = """# {title}
315
 
316
  This project was generated using [AnyCoder](https://huggingface.co/spaces/ahsenkhaliq/anycoder), an AI-powered code generator.
317
 
 
321
 
322
  ## Generated Prompts
323
 
324
+ {prompts_text}
325
 
326
  ## View Live
327
 
 
331
  *Generated with ❤️ using AnyCoder*
332
  """
333
 
334
+ readme_content = readme_template.format(title=title, prompts_text=prompts_text, repo_name=repo_name)
335
+
336
  user_hf_api.upload_file(
337
  path_or_fileobj=readme_content.encode('utf-8'),
338
  path_in_repo="README.md",