コード例 #1
0
def getAttendance():
    print(request.form['username'], request.form['password'])
    login_to_website(request.form['username'], request.form['password'])
    calendarJSON = Calendar2JSON()
    respo = Response(calendarJSON, 200)
    respo.headers['Content-Type'] = "application/json"
    return respo
コード例 #2
0
def getAttendance():
    print(request.form['username'], request.form['password'])
    login_to_website(request.form['username'], request.form['password'])
    attendanceJSON = Attendance2JSON()
    marksJSON = Internals2JSON()
    calendarJSON = Calendar2JSON()
    name = name_scrape()
    namescrape = {'name': name}
    calendarfinal = json2html.convert(json=calendarJSON['calendar'])
    attendancefinal = json2html.convert(json=attendanceJSON['attendance'])
    markfinal = json2html.convert(json=marksJSON['marks'])
    url = "https://slcm.manipal.edu/imagereader.aspx"
    imagelink = image_scrape()
    imagepath = imagelink.split("ImagePath=", 1)[1]
    querystring = {"FileName": "", "ImagePath": "{}".format(imagepath)}
    response = requests.request("GET", url, params=querystring)
    image = Image.open(io.BytesIO(response.content))
    encoded = base64.b64encode(response.content).decode('UTF-8')
    datauri = "data:image/png;base64," + encoded
    return render_template("afterlogin.html",
                           mark=markfinal,
                           greetingname=name,
                           atten=attendancefinal,
                           cal=calendarfinal,
                           datauri=datauri)
コード例 #3
0
def getAttendance():
    print(request.form['username'], request.form['password'])
    AttendanceHTML = login_to_website(request.form['username'],
                                      request.form['password'])
    attendanceJSON = Attendance2JSON(AttendanceHTML)
    respo = Response(attendanceJSON, 200)
    respo.headers['Content-Type'] = "application/json"
    return respo
コード例 #4
0
def getAttendance():
    print(request.form['username'], request.form['password'])
    AttendanceHTML, MarksHTML, CalendarHTML = login_to_website(
        request.form['username'], request.form['password'])
    calendarJSON = Calendar2JSON(CalendarHTML)
    marksJSON = Internals2JSON(MarksHTML)
    attendanceJSON = Attendance2JSON(AttendanceHTML)
    respo = Response(calendarJSON, 200)
    respo.headers['Content-Type'] = "application/json"
    return respo
コード例 #5
0
def handleRequest():
    request_body = request.get_json()
    username = request_body['username']
    password = request_body['password']
    tpe = request_body['type']
    if (tpe == "ATTENDANCE"):
        attd, _, _ = login_to_website(username, password)
        jsn = Attendance2JSON(attd)
        resp = Response(jsn, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "MARKS"):
        _, marks, _ = login_to_website(username, password)
        jsn = Internals2JSON(marks)
        resp = Response(jsn, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "CALENDAR"):
        _, _, calendar = login_to_website(username, password)
        jsn = Calendar2JSON(calendar)
        resp = Response(jsn, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "ALL"):
        attd, marks, calendar = login_to_website(username, password)
        jsn1 = Internals2JSON(marks)
        jsn2 = Attendance2JSON(attd)
        jsn3 = Calendar2JSON(calendar)
        jsn = dict()
        jsn['marks'] = jsn1
        jsn['attendance'] = jsn2
        jsn['calendar'] = jsn3
        resp = Response(dumps(jsn), 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    else:
        resp = Response("Error", 501)
        return resp
    return "Error Occured"
コード例 #6
0
def handleRequest():
    request_body = request.get_json()
    username = request_body["username"]
    password = request_body["password"]
    tpe = request_body["type"]
    if (tpe == "ATTENDANCE"):
        attd = login_to_website(username, password)
        jsn = Attendance2JSON(attd)
        resp = Response(jsn, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "ALL"):
        attd, marks = login_to_website(username, password)
        jsn2 = Attendance2JSON(attd)
        jsn = dict()
        jsn['attendance'] = jsn2
        resp = Response(dumps(jsn), 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    else:
        resp = Response("Error", 501)
        return resp
    return "Error Occured"
コード例 #7
0
def handleRequest():
    request_body = request.get_json()
    username = request_body['username']
    password = request_body['password']
    tpe = request_body['type']
    if (tpe == "ATTENDANCE"):
        login_to_website(username, password)
        jsn = Attendance2JSON()
        jsonfinal = dumps(jsn, indent=4, sort_keys=True)
        resp = Response(jsonfinal, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "MARKS"):
        login_to_website(username, password)
        jsn = Internals2JSON()
        jsonfinal = dumps(jsn, indent=4, sort_keys=True)
        resp = Response(jsonfinal, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "CALENDAR"):
        login_to_website(username, password)
        jsn = Calendar2JSON()
        jsonfinal = dumps(jsn, indent=4, sort_keys=True)
        resp = Response(jsonfinal, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    elif (tpe == "ALL"):
        login_to_website(username, password)
        jsn1 = Internals2JSON()
        jsn2 = Attendance2JSON()
        jsn3 = Calendar2JSON()
        name = name_scrape()
        image = image_scrape()
        imagescrape = {'imageurl': image}
        namescrape = {'name': name}
        jsn = {**namescrape, **imagescrape, **jsn2, **jsn1, **jsn3}
        jsonfinal = dumps(jsn, indent=4, sort_keys=True)
        resp = Response(jsonfinal, 200)
        resp.headers['Content-Type'] = "application/json"
        return resp
    else:
        resp = Response("Error", 501)
        return resp
    return "Error"