Spaces:
Paused
Paused
File size: 670 Bytes
c59bca4 bfcb19a c59bca4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | with open("server.js", "r") as f:
content = f.read()
# Since I ran the patch twice (once successfully with the first script despite the warning, and once with the second), it might be duplicated.
# Let's remove the block if it exists multiple times.
import re
# Find how many times it exists
pattern = r"// Utility to extract variables from template content.*?// POST /api/sessions/from-template.*?\n\}\);"
matches = re.findall(pattern, content, flags=re.DOTALL)
if len(matches) > 1:
print(f"Found {len(matches)} duplications. Removing all but the first.")
content = content.replace(matches[0], "")
with open("server.js", "w") as f:
f.write(content)
|