---
type: "Source File"
title: "app_path = \"/home/ben/infra/copecheck/app.py\""
description: "app_path = \"/home/ben/infra/copecheck/app.py\" with open(app_path, \"r\") as f: content = f.read() marker = \"import model_cope\\nmodel_cope.init_model_cope()\" if marker in content and \"md2html\" not in content: md_filter =."
resource: "https://www.copecheck.com"
tags: ["copecheck", "main", "source-file", "py"]
timestamp: "2026-05-09T19:56:40Z"
site: "main"
source_path: "copecheck/fix_md_filter.py"
---

# app_path = "/home/ben/infra/copecheck/app.py"

Source path: `copecheck/fix_md_filter.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-05-09T19:56:40Z`

```py
app_path = "/home/ben/infra/copecheck/app.py"
with open(app_path, "r") as f:
    content = f.read()

marker = "import model_cope\nmodel_cope.init_model_cope()"
if marker in content and "md2html" not in content:
    md_filter = '''

@app.template_filter("md2html")
def md2html(text):
    if not text:
        return ""
    import markdown as _md
    return _md.markdown(str(text), extensions=["nl2br", "fenced_code", "tables"])
'''
    content = content.replace(marker, marker + md_filter)
    with open(app_path, "w") as f:
        f.write(content)
    print("Added md2html filter")
else:
    print("Filter already exists or marker not found")
```
