Spaces:
Running
Running
| 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() | |