CoCalc Public Fileswww / cgi-bin / mfd / mfe_full_html.pyOpen with one click!
Author: William A. Stein
Compute Environment: Ubuntu 18.04 (Deprecated)
1
#!/usr/bin/python
2
3
# mfe_full_html.py
4
# (c) William Stein, 2003
5
# If the input is valid render the page.
6
7
import cgi, mfd, mfe_full, string, mfe_misc
8
9
form = cgi.FieldStorage()
10
11
print "Content-Type: text/html" # HTML is following
12
print # blank line, end of headers
13
14
error_msg = ""
15
16
x = mfe_full.is_valid(form)
17
if x[0]: # is valid
18
N = int(x[1])
19
k = int(x[2])
20
else:
21
error_msg = "<font color=red>Error: The level must be between 1 and 10^9 and the weight must be an integer between 2 and 10^9.</font><br>"
22
if form.has_key("level_fallback") and form.has_key("weight_fallback"):
23
N = int(form["level_fallback"].value)
24
k = int(form["weight_fallback"].value)
25
else:
26
N = 11
27
k = 2
28
29
def simplest_possible_character(N,k): # with correct parity
30
eps = '1'
31
if mfd.characters_are_known(N) and k%2 == 1:
32
chars = mfd.characters(N)
33
x = [[int(c['degree']),c['label'],c['parity']] for c in chars]
34
x.sort()
35
for chi in x:
36
if chi[2] == -1:
37
eps = chi[1]
38
break
39
return eps
40
41
if form.has_key('character'):
42
eps_mod = form['character'].value
43
eps_mod = string.split(eps_mod,':')
44
eps = eps_mod[0]
45
mod = int(eps_mod[1])
46
if mod != N:
47
eps = simplest_possible_character(N,k)
48
else:
49
eps = simplest_possible_character(N,k)
50
51
web_page = mfe_full.html_space(N, k, eps, error_msg)
52
print web_page
53