Added API LogFileView
This commit is contained in:
parent
654f7229bd
commit
f1d0ea5b28
1 changed files with 14 additions and 15 deletions
|
|
@ -23,7 +23,7 @@ from datetime import datetime
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from flask import abort, send_file
|
from flask import abort, send_file
|
||||||
from flask_cors import CORS, cross_origin
|
from flask_cors import CORS, cross_origin
|
||||||
from labthings import create_app
|
from labthings import create_app, View
|
||||||
from labthings.extensions import find_extensions
|
from labthings.extensions import find_extensions
|
||||||
|
|
||||||
from openflexure_microscope.api.microscope import default_microscope as api_microscope
|
from openflexure_microscope.api.microscope import default_microscope as api_microscope
|
||||||
|
|
@ -139,6 +139,19 @@ for name, action in views.enabled_root_actions().items():
|
||||||
rule = action["rule"]
|
rule = action["rule"]
|
||||||
labthing.add_view(view_class, f"/actions{rule}")
|
labthing.add_view(view_class, f"/actions{rule}")
|
||||||
|
|
||||||
|
# Add log file view
|
||||||
|
class LogFileView(View):
|
||||||
|
def get(self):
|
||||||
|
"""
|
||||||
|
Most recent 1mb of log output
|
||||||
|
"""
|
||||||
|
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||||
|
return send_file(
|
||||||
|
ROOT_LOGFILE,
|
||||||
|
as_attachment=True,
|
||||||
|
attachment_filename="openflexure_microscope_{}.log".format(timestamp),
|
||||||
|
)
|
||||||
|
labthing.add_view(LogFileView, "/log")
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def openflexure_ev():
|
def openflexure_ev():
|
||||||
|
|
@ -153,20 +166,6 @@ def routes():
|
||||||
"""
|
"""
|
||||||
return list_routes(app)
|
return list_routes(app)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/log")
|
|
||||||
def err_log():
|
|
||||||
"""
|
|
||||||
Most recent 1mb of log output
|
|
||||||
"""
|
|
||||||
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
|
||||||
return send_file(
|
|
||||||
ROOT_LOGFILE,
|
|
||||||
as_attachment=True,
|
|
||||||
attachment_filename="openflexure_microscope_{}.log".format(timestamp),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/v1/", defaults={"path": ""})
|
@app.route("/api/v1/", defaults={"path": ""})
|
||||||
@app.route("/api/v1/<path:path>")
|
@app.route("/api/v1/<path:path>")
|
||||||
def api_v1_catch_all(path): # pylint: disable=W0613
|
def api_v1_catch_all(path): # pylint: disable=W0613
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue