-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
78 lines (57 loc) · 1.7 KB
/
Copy pathserver.py
File metadata and controls
78 lines (57 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import json
import os.path
import cherrypy
from cherrypy.lib.static import serve_file
import jinja2
import jinja2plugin
import jinja2tool
import utils
class Labo1():
@cherrypy.expose
def index(self):
pass
@cherrypy.expose
def fact(self):
pass
@cherrypy.expose
def Answer_fact(self, number):
try:
nbr = int(number)
x = str(utils.fact(nbr))
return {"number": number, "fact": x}
except:
return {"number": number, "fact": "None"}
@cherrypy.expose
def roots(self):
pass
@cherrypy.expose
def Answer_roots(self, number_a, number_b, number_c):
try:
a = int(number_a)
b = int(number_b)
c = int(number_c)
x1, x2, delta = utils.roots(a, b, c)
root1 = str(x1)
root2 = str(x2)
delta = str(delta)
function = str(a) + 'x²+' + str(b) + 'x+' + str(c) + '=0'
return {"x1": root1, "x2": root2, "delta": delta, "function": function}
except:
pass
@cherrypy.expose
def integrate(self):
pass
@cherrypy.expose
def Answer_integ(self, function, lower, upper):
try:
a = int(lower)
b = int(upper)
integrate = utils.integrate(function, a, b)
return {"function": function, "result": integrate}
except:
pass
if __name__ == '__main__':
ENV = jinja2.Environment(loader=jinja2.FileSystemLoader('.'))
jinja2plugin.Jinja2TemplatePlugin(cherrypy.engine, env=ENV).subscribe()
cherrypy.tools.template = jinja2tool.Jinja2Tool()
cherrypy.quickstart(Labo1(),'','serveur.conf')