CoCalc Public Fileswww / cgi-bin / mfd / test.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 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
x = [True, 11,2]
18
if x[0]: # is valid
19
N = int(x[1])
20
k = int(x[2])
21
else:
22
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>"
23
if form.has_key("level_fallback") and form.has_key("weight_fallback"):
24
N = int(form["level_fallback"].value)
25
k = int(form["weight_fallback"].value)
26
else:
27
N = 11
28
k = 2
29
30
def simplest_possible_character(N,k): # with correct parity
31
eps = '1'
32
if mfd.characters_are_known(N) and k%2 == 1:
33
chars = mfd.characters(N)
34
x = [[int(c['degree']),c['label'],c['parity']] for c in chars]
35
x.sort()
36
for chi in x:
37
if chi[2] == -1:
38
eps = chi[1]
39
break
40
return eps
41
42
eps = simplest_possible_character(N,k)
43
44
45
web_page = mfe_full.html_space(N, k, eps, error_msg)
46
print web_page
47