Example #1
0
File: ar.py Project: imtxc/pm25
@app.route("/id/<uuid>/hum/<hum>/tmp/<tmp>/mq9/<mq9>/dn7/<dn7>")
def submit_value(uuid, hum, tmp, mq9, dn7):
    "Return 200 OK to avoid UUID hijack"
    try:
        hum = float(hum)
        tmp = float(tmp)
        mq9 = float(mq9)
        dn7 = float(dn7)
        assert re_uuid.match(uuid) is not None
    except:
        raise
        return "OK", 200
    conn = g.db
    c = conn.cursor()
    c.execute('insert into log values (?, datetime("now"), ?, ?, ?, ?)', (uuid, hum, tmp, mq9, dn7))
    conn.commit()
    c.close()
    return "OK", 200


@app.route("/register")
def register():
    u = str(uuid.uuid4())
    return u, 200


if __name__ == "__main__":
    app.config["JSON_AS_ASCII"] = False  # JSON in UTF-8
    app.config["DEBUG"] = False
    task_sheethub()
    app.run(host="0.0.0.0", threaded=True, port=2080)
Example #2
0
import datetime
import json
import os
import re
import sys
import time
import uuid
import sh
from bs4 import BeautifulSoup
from flask import Flask, render_template, request, redirect, url_for, jsonify, Markup

app = Flask(__name__)
app.config["JSON_AS_ASCII"] = False

# Website Endpoints


@app.errorhandler(500)
def internal_error(exception):
    """Render the error template with the error message."""
    return render_template("500.html", error=exception, version=sys.version, path=sys.executable, env=os.environ), 500


@app.route("/")
def index():
    return render_template("landing.html")


@app.route("/main/<participant_id>/<order>")
def main(participant_id, order):
    return render_exp("index.html", participant_id, order, "MAIN")