示例#1
0
def query():
    form = queryForm()
    if form.validate_on_submit():
        searchtype = form.searchtype.data
        conn = mysql.connector.connect(user='******',
                                       password='',
                                       database='Bookdata')
        cursor = conn.cursor()
        if searchtype == '1':
            cursor.execute('select * from Book')
            results = cursor.fetchall()
            cursor.close()
            return render_template('queryinit1.html',
                                   form=form,
                                   list=results,
                                   type=searchtype)

        else:
            cursor.execute(
                'select book.id,book.name,borrow.userid from Borrow,Book where borrow.bookid = book.id group by borrow.userid'
            )
            results = cursor.fetchall()
            cursor.close()
            return render_template('queryinit.html',
                                   form=form,
                                   list=results,
                                   type=searchtype)

    return render_template('queryinit.html', form=form, list=[], type=0)
示例#2
0
def index():
	markers = get_markers(None)
	if request.args.get('rating', '') != "":
		query = [request.args.get('company', ''), request.args.get('job_type', ''), int(request.args.get('rating', ''))]
		markers = get_markers(query)
	addform = addForm()
	queryform = queryForm()
	return render_template('index.html', markers=markers, addform=addform, queryform=queryform)
示例#3
0
def query():
	query = queryForm(request.form)
	return redirect(url_for('index', rating=query.rating.data, company=query.company.data, job_type=query.job_type.data))
示例#4
0
def index():
    form = queryForm()
    if form.validate_on_submit():
        a = {}
        a["Inputs"] = {}
        a["Inputs"]["input1"] = {}
        a["Inputs"]["input1"]["ColumnNames"] = [
            "symboling", "normalized-losses", "make", "fuel-type",
            "aspiration", "num-of-doors", "body-style", "drive-wheels",
            "engine-location", "wheel-base", "length", "width", "height",
            "curb-weight", "engine-type", "num-of-cylinders", "engine-size",
            "fuel-system", "bore", "stroke", "compression-ratio", "horsepower",
            "peak-rpm", "city-mpg", "highway-mpg", "price"
        ]
        a["Inputs"]["input1"]["Values"] = [
            [
                form.sym.data, form.nor.data, form.mak.data, form.fue.data,
                form.asp.data, form.nod.data, form.bod.data, form.dri.data,
                form.eng.data, form.whe.data, form.len.data, form.wid.data,
                form.hei.data, form.cur.data, form.engt.data, form.noc.data,
                form.engs.data, form.fues.data, form.bor.data, form.stro.data,
                form.com.data, form.hor.data, form.pea.data, form.cit.data,
                form.hig.data, form.pri.data
            ],
            [
                form.sym.data, form.nor.data, form.mak.data, form.fue.data,
                form.asp.data, form.nod.data, form.bod.data, form.dri.data,
                form.eng.data, form.whe.data, form.len.data, form.wid.data,
                form.hei.data, form.cur.data, form.engt.data, form.noc.data,
                form.engs.data, form.fues.data, form.bor.data, form.stro.data,
                form.com.data, form.hor.data, form.pea.data, form.cit.data,
                form.hig.data, form.pri.data
            ]
        ]
        a["GlobalParamenters"] = ""
        body = str.encode(json.dumps(a))

        url = 'https://ussouthcentral.services.azureml.net/workspaces/98f09e8bdaf14d8ca8003c16f867a661/services/232decf47f234957aa8e63e34ae0347a/execute?api-version=2.0&details=true'
        api_key = 'BsQKb4MJaoH2psrE7wS7PR4Z3BT+2vMutHWTjtkHV40a7pfwwQMjCr0xfGdtns1vZkZzi0kcLdHALQPLNAcAvw=='  # Replace this with the API key for the web service
        headers = {
            'Content-Type': 'application/json',
            'Authorization': ('Bearer ' + api_key)
        }

        req = urllib.request.Request(url, body, headers)

        response = urllib.request.urlopen(req)

        result = response.read()
        result = result.decode("utf-8")
        sst = json.loads(result)
        return render_template(
            "index.html",
            title="二手车缘分系统",
            error='Not Right',
            form=form,
            predictprice=sst["Results"]["output1"]["value"]["Values"][0][8])
    return render_template("index.html",
                           title="二手车缘分系统",
                           error='Not Right',
                           form=form,
                           predictprice=0)