示例#1
0
def view_paste(pasteid):
    status, data, code = logic.view_existing_paste(pasteid, config)

    if (status == "ERROR"):
        return Response(
            render_template("index.html",
                            config=config,
                            version=VERSION,
                            error=data,
                            page="new"), code)

    if (status == "OK"):
        paste_date = datetime.fromtimestamp(
            int(data[1]) + time.altzone + 3600).strftime("%H:%M:%S %d/%m/%Y")

        paste_size = logic.format_size(len(data[0].encode('utf-8')))

    if (status == "WARNING"):
        paste_date = "Not available."

    return Response(
        render_template("view.html",
                        content=data[0],
                        date=paste_date,
                        size=paste_size,
                        pid=pasteid,
                        config=config,
                        version=VERSION,
                        page="view"), 200)
示例#2
0
def raw_paste(pasteid):
    status, data, code = logic.view_existing_paste(pasteid, config)

    if (status == "ERROR" and code >= 500):
        return Response(data, code, mimetype="text/plain")
    if (status == "ERROR"):
        return Response("No such paste", code, mimetype="text/plain")
    return Response(data[0], mimetype="text/plain")