[+] Create server
This commit is contained in:
+23
-2
@@ -30,8 +30,29 @@ def generate_report() -> str:
|
||||
return '\n'.join(md)
|
||||
|
||||
|
||||
return markdown.markdown('\n'.join(md), extensions=['tables'])
|
||||
def serve_report() -> None:
|
||||
"""
|
||||
Serve report page in a http server.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
# Create flask app
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/')
|
||||
def root() -> str:
|
||||
# Generate report, put report into HTML
|
||||
html = read(str(src_dir.joinpath('report_page.html'))) \
|
||||
.replace('{{markdown}}', generate_report().replace('`', '\\`'))
|
||||
return html
|
||||
|
||||
@app.route('/<path:path>')
|
||||
def res(path: str):
|
||||
path = os.path.join(REPORT_DIR, path)
|
||||
return send_from_directory(Path(path).absolute().parent, Path(path).name)
|
||||
|
||||
app.run()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(generate_report())
|
||||
serve_report()
|
||||
|
||||
Reference in New Issue
Block a user