Spaces:
Running
Running
File size: 994 Bytes
590dfc1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import os
import re
from pathlib import Path
def main():
with open("app.py", "r", encoding="utf-8") as f:
content = f.read()
# Create directories
os.makedirs("core", exist_ok=True)
os.makedirs("api", exist_ok=True)
os.makedirs("ui/templates", exist_ok=True)
# 1. Extract HTML Template
# def _render_index_html( ... ) -> str: ... template = """<!doctype html>...""" return template
html_match = re.search(r'template = """(.*?)"""\s*replacements = {', content, re.DOTALL)
if html_match:
html_content = html_match.group(1).strip()
with open("ui/templates/index.html", "w", encoding="utf-8") as f:
f.write(html_content)
print("Extracted ui/templates/index.html")
# Replace the massive string in app.py with a file read (temporarily)
# to ensure we don't lose logic. Wait, it's better to create ui/render.py
else:
print("HTML template not found.")
if __name__ == "__main__":
main()
|