CoCalc Public Fileswww / cgi-bin / mfd / mfe_known_html.pyOpen with one click!
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
5
import mfe_known, mfe_full, constants, mfe_misc
6
import cgi # cgi-bin
7
import Documents, HTML
8
9
10
def 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
25
def 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
34
def 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
41
print "Content-Type: text/html" # HTML is following
42
print # blank line, end of headers
43
44
form = cgi.FieldStorage()
45
46
level_weight = form["level_weight"].value
47
x = mfe_misc.parse_level_weight(level_weight)
48
no_error = x[0]
49
if not no_error:
50
msg = x[1]
51
52
level = x[1]
53
weight = x[2]
54
55
table = form["table"].value
56
57
if no_error:
58
kd = mfe_known.KnownData(level, weight, table)
59
60
doc = Documents.Document()
61
doc.append(HTML.TITLE('The Modular Forms Explorer: Graphical Diagrams of Database Content'))
62
doc.append(HTML.LINK(rel="stylesheet", type="text/css", \
63
HREF="/mfd/mfd.css", TITLE="was"))
64
65
body = HTML.BODY(klass="top")
66
doc.append(body)
67
68
body.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
72
if no_error:
73
s = '<form action="mfe_known_html.py" method="get">'+\
74
'<center><table border=0 cellpadding=5>'+\
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
82
else:
83
s = "<hr><b>ERROR:</b> <font color=red>%s</font>"%msg
84
body.append(s)
85
86
print doc
87
88
89
90
91
92