44 lines
958 B
Python
Executable File
44 lines
958 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from flask import Flask, redirect, request, render_template, send_from_directory
|
|
from . import db
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
@app.route("/")
|
|
def hello_world():
|
|
conn = db.get()
|
|
objects = db.Object.all(conn)
|
|
return render_template('index.html', objects=objects)
|
|
|
|
|
|
@app.route("/create-object/", methods=["POST"])
|
|
def create_object():
|
|
conn = db.get()
|
|
with conn:
|
|
db.Object.create(request.form.get('name'), conn)
|
|
return redirect('/')
|
|
|
|
|
|
@app.route('/object/<id>')
|
|
def object(id: int):
|
|
conn = db.get()
|
|
object = db.Object.get_from_id(id, conn)
|
|
return render_template('object.html', object=object)
|
|
|
|
|
|
@app.route("/calibration")
|
|
def calibration():
|
|
return render_template('calibration.html')
|
|
|
|
|
|
@app.route('/static/<path:path>')
|
|
def send_static(path):
|
|
return send_from_directory('static', path)
|
|
|
|
|
|
@app.route('/data/<path:path>')
|
|
def send_data(path):
|
|
return send_from_directory('data', path)
|