-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add simple web server for mermaid diagrams preview
- Loading branch information
Showing
5 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import markdown | ||
import markdown_mermaidjs | ||
|
||
from flask import Flask | ||
from settings import MACHINE_ROOT | ||
|
||
SIMPLE_CSS = '<link rel="stylesheet" ' \ | ||
'href="https://unpkg.com/simpledotcss/simple.min.css">' \ | ||
'<style>' \ | ||
'h1,h2,h3,h4,h5,h6 { margin: 0.5rem; }' \ | ||
'p { margin: 0.5rem; }' \ | ||
'</style>' | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def readme(): | ||
with open(os.path.join(MACHINE_ROOT, 'README.md')) as f: | ||
html = markdown.markdown( | ||
f.read(), extensions=["markdown_mermaidjs"] | ||
) | ||
return SIMPLE_CSS + html | ||
|
||
if __name__ == '__main__': | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mistune | ||
flask | ||
markdown-mermaidjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import os | ||
# __file__ refers to the file settings.py | ||
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) | ||
MACHINE_ROOT = os.path.join(APP_ROOT, '../') |