CoCalc Public Fileswww / cgi-bin / mfd / mfe_known_html.py
Author: William A. Stein
Compute Environment: Ubuntu 18.04 (Deprecated)
1#!/usr/bin/python
2# mfe_known_html.py
3# (c) William Stein, 2001, [email protected]
4
5import mfe_known, mfe_full, constants, mfe_misc
6import cgi  # cgi-bin
7import Documents, HTML
8
9
10def verify_input(level_min, level_max, weight_min, weight_max):
11    if level_min < 1:
12        return [1,"The smaller level must be at least 1."]
13    if level_min > level_max:
14        return [1, "The lower level can not be larger than the upper level."]
15    if weight_min < 1:
16        return [1,"The smaller weight must be at least 1."]
17    if weight_min > weight_max:
18        return [1, "The lower weight can not be bigger than the upper weight."]
19    if level_max - level_min > mfe_known.lv_max_range:
20        return [1, "The difference of the levels can be at most %s."%mfe_known.lv_max_range]
21    if weight_max - weight_min > mfe_known.wt_max_range:
22        return [1, "The difference of the weights can be at most %s."%mfe_known.wt_max_range]
23    return [0, ""]
24
25def table_selector(table):
26    s = '<SELECT TYPE="submit" name="table">'
27    for x in constants.TABLES_ARRAY:
28        s = s+'<OPTION'
29        if x == table:
30            s = s+ ' selected '
31        s = s+' value="%s">%s</OPTION>'%(x, x)
32    return s
33
34def level_weight_selector():
35    s = '<input type="submit" value="Center level and weight at"><br>'+\
36        '<INPUT TYPE="text" NAME="level_weight" VALUE="      %s">'%level_weight
37    return s
38
39
40
41print "Content-Type: text/html"      # HTML is following
42print                                # blank line, end of headers
43
44form = cgi.FieldStorage()
45
46level_weight = form["level_weight"].value
47x = mfe_misc.parse_level_weight(level_weight)
48no_error = x[0]
49if not no_error:
50    msg = x[1]
51
52level = x[1]
53weight = x[2]
54
55table = form["table"].value
56
57if no_error:
58    kd = mfe_known.KnownData(level, weight, table)
59
60doc = Documents.Document()
61doc.append(HTML.TITLE('The Modular Forms Explorer: Graphical Diagrams of Database Content'))
63                     HREF="/mfd/mfd.css", TITLE="was"))
64
65body = HTML.BODY(klass="top")
66doc.append(body)
67
68body.append(HTML.CENTER(HTML.H1('<a href="/mfd/mfe">The Modular Forms Explorer</a>'), \
69                        HTML.H3("Click on a box to go to spaces of modular forms of that weight and level.")))
70
71
72if no_error:
73    s = '<form action="mfe_known_html.py" method="get">'+\
75          '<tr><td align=center>' + level_weight_selector() + '</td>' +\
76          '<td width=30></td><td align=center>'+\
77          '<input type="submit" value="Darken depending on how much is known">&nbsp&nbsp<br>' + \
78          table_selector(table) + '</b></td></tr>'+\
79          '<tr><td colspan=3 align=center>' + kd.html_table() + '</td></tr></table></center> </form>'
80    body.append(s)
81
82else:
83    s = "<hr><b>ERROR:</b> <font color=red>%s</font>"%msg
84    body.append(s)
85
86print doc
87
88
89
90
91
92