Ejemplo n.º 1
0
def buildAccountLinks(loggedin=False, redirect=None):
	html = """
		<a href="/getacc.py?redirect=%2Faccount.py" class="icon"><i class="fas fa-user-circle"></i></a>
		<a href="{}">{}</a>
	"""
	if loggedin:
		if redirect:
			return html.format('/signout.py?redirect={}'.format(urllib.parse.quote_plus(str(redirect), safe='')), 'Sign out')
		else:
			return html.format('/signout.py', 'Sign out')
	elif redirect:
		return html.format('/getacc.py?redirect={}'.format(urllib.parse.quote_plus(str(redirect), safe='')), 'Sign in')
	else:
		return html.format('/getacc.py', 'Sign in')
Ejemplo n.º 2
0
def registrar():
    global _registrar
    if not _registrar:
        from Registrar import Registrar
        _registrar = Registrar()

        import native
        _registrar.manage(native, native.format())

        import chemkin
        _registrar.manage(chemkin, chemkin.format())

        import ckml
        _registrar.manage(ckml, ckml.format())

        import c
        _registrar.manage(c, c.format())

        import html
        _registrar.manage(html, html.format())

        import python
        _registrar.manage(python, python.format())

    return _registrar
Ejemplo n.º 3
0
def create_download_link(df, title="Download CSV file", filename="data.csv"):
    csv = df.to_csv()
    b64 = base64.b64encode(csv.encode())
    payload = b64.decode()
    html = '<a download="{filename}" href="data:text/csv;base64,{payload}" target="_blank">{title}</a>'
    html = html.format(payload=payload, title=title, filename=filename)
    return HTML(html)
Ejemplo n.º 4
0
    def switch_exp(self, data, suffix=""):
        html = self.resource_string("static/html/experiment.html")
        frag = Fragment(html.format(self=self))
        frag.add_css(self.resource_string("static/css/dcxblock.css"))
        frag.add_javascript(self.resource_string("static/js/src/dcxblock.js"))
        frag.initialize_js('DcXBlock')

        return frag
Ejemplo n.º 5
0
    def student_view(self, context=None):
        """
        The primary view of the DcXBlock, shown to students
        when viewing courses.
        """
        
        html = self.resource_string("static/html/dcxblock.html")
        frag = Fragment(html.format(self=self))
        frag.add_css(self.resource_string("static/css/dcxblock.css"))
        frag.add_javascript(self.resource_string("static/js/src/dcxblock.js"))
        frag.initialize_js('DcXBlock')

        return frag
Ejemplo n.º 6
0
    def studio_view(self, context):
        """
        Create a fragment used to display the edit view in the Studio.
        """

        
        html = self.resource_string("static/html/studio_dcxblock.html")

        frag = Fragment(html.format(dc_cdn=self.dc_cdn, dc_grade=self.dc_grade, dc_code=self.dc_code, dc_student_tries=self.dc_student_tries, dc_id=self.dc_id))

        frag.add_javascript(self.resource_string("static/js/src/studio_dcxblock.js"))
        frag.initialize_js('DcXBlock')

        return frag
Ejemplo n.º 7
0
def hello():

    # try:
    #     visits = redis.incr("counter")
    # except RedisError:
    #     visits = "<i>cannot connect to Redis, counter disabled</i>"

    # date =''

    html = "<h1>CSC 462 Distributed Systems Project!</h1>" \
    "<h2>Meghan Fair V00839675</h2>" \
    "<b>Hostname:</b>{hostname}<br/>" \
    # "<b>Visits:</b> {visits}" \
    # "<br>{title}<br>" \

    # p = h.h1("CSC 462 Distributed Systems Project!")
    # p.br
    # h.h2("Meghan Fair V00839675")
    # p.br

    string = ""
    h=""
    l = ""
    headerRow=[]

    dataSet = []
    with open("test_data.csv", "r") as csv_file:
        lines = csv_file.readlines()
        data_title = lines[0]
        # p+=data_title
        second_line = lines[1]
        headerRow = second_line.split(",")

        # string += "<table>"\
        #     "<tr>"\
        # for i in range(headerRow):
        #     string += "<th>{headerrow[i]}</th>"\
        # string += "</tr>"
        
        string = "<table>"\
            "<tr>"\
                "<th>{headerRow0}</th>"\
                "<th>{headerRow1}</th>"\
                "<th>{headerRow2}</th>"\
                "<th>{headerRow3}</th>"\
                "<th>{headerRow4}</th>"\
            "</tr>"\
        # l = html.format(headerRow0 = headerRow[0], headerRow1 = headerRow[1],headerRow2 = headerRow[2],headerRow3 = headerRow[3],headerRow4 = headerRow[4])
        # t = h.table()
        # r = t.tr
        # r.th(headerRow[0])
        # r.th(headerRow[1])
        # r.th(headerRow[2])
        # r.th(headerRow[3])
        # r.th(headerRow[4])

        l = lines[2:]
        for i in l:
            row = i.split(",")
            date = row[0]
            salinity = row[1]
            temp = row[2]
            latitude = row[3]
            longitude = row[4]

            
            
            
            dataString = "<tr>"\
                "<td>{date}</td"\
                "<td>{salinity}</td"\
                "<td>{temp}</td"\
                "<td>{latitude}</td"\
                "<td>{longitude}</td"\
                "</tr>"\

            string += dataString

            # data_row = t.tr
            # data_row.td(date)
            # data_row.td(salinity)
            # data_row.td(temp)
            # data_row.td(latitude)
            # data_row.td(longitude)

    string += "</table>"


    h = dataString.format(date=date, salinity=salinity, temp=temp, latitude=latitude, longitude=longitude)
    print(string)
    f = html.format(name=os.getenv("NAME", "Meghan"), hostname=socket.gethostname(), visits=visits)
    l = string.format(headerRow0 = headerRow[0], headerRow1 = headerRow[1],headerRow2 = headerRow[2],headerRow3 = headerRow[3],headerRow4 = headerRow[4])