Esempio n. 1
0
File: doh.py Progetto: munk/Homer
def browse():
    if request.method == 'POST':
        requested_boro = request.form['boro']
        requested_cuisine = cuisine_codes.get(int(request.form['cuisine']), False)
        data = model.get_summary(requested_boro, requested_cuisine, mongo)
        violations = []
        viol_grp = data.groupby('VIOLCODE')
        violations = [(vl.get(name, "Unknown"), frame.CAMIS.count()) for name, frame in viol_grp]

        return render_template('summary.html', cuisine=requested_cuisine, boro=requested_boro, data=data, violations=violations)
    return render_template('browse.html', cuisine_codes=cuisine_codes)
Esempio n. 2
0
 def GET(self, job_id):
     web.header('Content-Type', 'application/json')
     db_path = os.path.join(base_path, 'static', 'results', job_id,
                            'crispr.db')
     return model.get_summary(db_path)
#!/home/slamphear/miniconda2/bin/python
import cgi
import sys
import model as md
import json

# -----------
# boiler plate
# -----------
fs = cgi.FieldStorage()
sys.stdout.write("Content-Type: application/json")
sys.stdout.write("\n")
sys.stdout.write("\n")
# -----------

l = md.get_summary()
result = json.dumps(l, indent=1)
# -----------
# boiler plate
# -----------
sys.stdout.write(result)
sys.stdout.write("\n")
sys.stdout.close()
Esempio n. 4
0
import sys

sys.path.insert(0, '/var/www/cgi-bin')
import model as md
import cgi, os
import cgitb

cgitb.enable()

fs = cgi.FieldStorage()

string = ""

try:
    if 'table' not in fs:
        # get request without specifying table name
        # return current summary
        string = md.get_summary(api=True)
        print("Content-Type: text/json\n")
    else:
        # get request with table name
        # return asked table
        string = md.get_summary(fs['table'].value, api=True)
        print("Content-Type: text/json\n")
except Exception as e:
    # unexpected error
    print('Status: 500 Internal Server Error\r\n\r\n')
    print(str(e))
else:
    print(string)