carlosduplar commited on
Commit ·
8f98bab
1
Parent(s): 04ea729
Add markdown rendering for /field-notes route
Browse files- requirements.txt +1 -0
- server_app.py +23 -24
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
gradio>=6.0,<7.0
|
| 2 |
httpx>=0.28,<1.0
|
|
|
|
| 3 |
numpy
|
| 4 |
piper-tts>=1.2,<2.0
|
|
|
|
| 1 |
gradio>=6.0,<7.0
|
| 2 |
httpx>=0.28,<1.0
|
| 3 |
+
markdown>=3.7,<4.0
|
| 4 |
numpy
|
| 5 |
piper-tts>=1.2,<2.0
|
server_app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import html
|
| 2 |
import logging
|
| 3 |
import os
|
| 4 |
import tempfile
|
|
@@ -8,6 +7,7 @@ from gradio.data_classes import FileData
|
|
| 8 |
from fastapi.responses import HTMLResponse, FileResponse
|
| 9 |
|
| 10 |
from core import process_turn, end_session_click, reset_session, make_initial_state
|
|
|
|
| 11 |
|
| 12 |
log = logging.getLogger(__name__)
|
| 13 |
logging.basicConfig(level=logging.INFO, force=True)
|
|
@@ -113,35 +113,35 @@ _FIELD_NOTES_HTML_TEMPLATE = """\
|
|
| 113 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 114 |
<title>Field Notes · Patient Virtuel</title>
|
| 115 |
<style>
|
| 116 |
-
*, *::before, *::after {
|
| 117 |
-
body {
|
| 118 |
background: #19120c; color: #efe0d4;
|
| 119 |
font-family: "EB Garamond", Georgia, serif;
|
| 120 |
line-height: 1.7; padding: 2rem 1rem;
|
| 121 |
-
}
|
| 122 |
-
article {
|
| 123 |
max-width: 720px; margin: 0 auto;
|
| 124 |
-
}
|
| 125 |
-
h1 {
|
| 126 |
-
h2 {
|
| 127 |
-
h3 {
|
| 128 |
-
p {
|
| 129 |
-
pre {
|
| 130 |
overflow-x: auto; font-size: 0.85rem; margin: 1rem 0;
|
| 131 |
-
border: 1px solid rgba(255,200,150,0.1); }
|
| 132 |
-
code {
|
| 133 |
-
font-size: 0.9em; }
|
| 134 |
-
table {
|
| 135 |
-
th, td {
|
| 136 |
-
th {
|
| 137 |
-
a {
|
| 138 |
-
hr {
|
| 139 |
-
ul, ol {
|
| 140 |
</style>
|
| 141 |
</head>
|
| 142 |
<body>
|
| 143 |
<article>
|
| 144 |
-
|
| 145 |
</article>
|
| 146 |
</body>
|
| 147 |
</html>"""
|
|
@@ -156,9 +156,8 @@ async def field_notes():
|
|
| 156 |
except FileNotFoundError:
|
| 157 |
return "<h1>Field Notes not found</h1>"
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
return _FIELD_NOTES_HTML_TEMPLATE.format(content=html_content)
|
| 162 |
|
| 163 |
|
| 164 |
if __name__ == "__main__":
|
|
|
|
|
|
|
| 1 |
import logging
|
| 2 |
import os
|
| 3 |
import tempfile
|
|
|
|
| 7 |
from fastapi.responses import HTMLResponse, FileResponse
|
| 8 |
|
| 9 |
from core import process_turn, end_session_click, reset_session, make_initial_state
|
| 10 |
+
from markdown import markdown
|
| 11 |
|
| 12 |
log = logging.getLogger(__name__)
|
| 13 |
logging.basicConfig(level=logging.INFO, force=True)
|
|
|
|
| 113 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 114 |
<title>Field Notes · Patient Virtuel</title>
|
| 115 |
<style>
|
| 116 |
+
*, *::before, *::after { margin: 0; box-sizing: border-box; }
|
| 117 |
+
body {
|
| 118 |
background: #19120c; color: #efe0d4;
|
| 119 |
font-family: "EB Garamond", Georgia, serif;
|
| 120 |
line-height: 1.7; padding: 2rem 1rem;
|
| 121 |
+
}
|
| 122 |
+
article {
|
| 123 |
max-width: 720px; margin: 0 auto;
|
| 124 |
+
}
|
| 125 |
+
h1 { font-size: 2rem; margin-bottom: 0.5rem; color: #ff5719; }
|
| 126 |
+
h2 { font-size: 1.4rem; margin: 2rem 0 0.5rem; color: #ff5719; }
|
| 127 |
+
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.3rem; color: #e6beb2; }
|
| 128 |
+
p { margin: 0.6rem 0; }
|
| 129 |
+
pre { background: #221a13; padding: 1rem; border-radius: 8px;
|
| 130 |
overflow-x: auto; font-size: 0.85rem; margin: 1rem 0;
|
| 131 |
+
border: 1px solid rgba(255,200,150,0.1); }
|
| 132 |
+
code { background: #221a13; padding: 0.1em 0.3em; border-radius: 4px;
|
| 133 |
+
font-size: 0.9em; }
|
| 134 |
+
table { border-collapse: collapse; margin: 1rem 0; width: 100%; }
|
| 135 |
+
th, td { border: 1px solid #5c4037; padding: 0.4rem 0.6rem; text-align: left; }
|
| 136 |
+
th { background: #312821; color: #ff5719; }
|
| 137 |
+
a { color: #ff5719; }
|
| 138 |
+
hr { border: none; border-top: 1px solid #5c4037; margin: 2rem 0; }
|
| 139 |
+
ul, ol { margin: 0.5rem 0 0.5rem 1.5rem; }
|
| 140 |
</style>
|
| 141 |
</head>
|
| 142 |
<body>
|
| 143 |
<article>
|
| 144 |
+
%s
|
| 145 |
</article>
|
| 146 |
</body>
|
| 147 |
</html>"""
|
|
|
|
| 156 |
except FileNotFoundError:
|
| 157 |
return "<h1>Field Notes not found</h1>"
|
| 158 |
|
| 159 |
+
body = markdown(raw, extensions=["fenced_code", "tables"])
|
| 160 |
+
return _FIELD_NOTES_HTML_TEMPLATE.replace("%s", body, 1)
|
|
|
|
| 161 |
|
| 162 |
|
| 163 |
if __name__ == "__main__":
|