-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathserver.py
executable file
·57 lines (45 loc) · 1.77 KB
/
server.py
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
from bottle import *
import settings
import util.compile as compile
from app import *
# Home Page
@get('/')
def index():
return template("index", {"info": settings.info})
# Simulate Page
@get('/simulate')
def simulate_get():
return template("simulate", {"info": settings.info,
"sigma": settings.sigma})
@post('/simulate')
def simulate_post():
parsed = run_simulation(request.forms, settings.sigma)
out = prepare_graphs(parsed, settings.graphs)
return template("results", {"info": settings.info,
"bind": out,
"parameters": request.forms,
"settings_params": settings.sigma['parameters']})
# Error 404 (when page is not found)
@error(404)
def error404(error):
return "Sorry, can't find that page!"
# Static Routes
@get('/<filename:re:.*\.js>')
def javascripts(filename):
return static_file(filename, root='static/js')
@get('/<filename:re:.*\.css>')
def stylesheets(filename):
return static_file(filename, root='static/css')
@get('/<filename:re:.*\.(jpg|png|gif|ico)>')
def images(filename):
return static_file(filename, root='static/img')
@get('/<filename:re:.*\.(eot|ttf|woff|svg)>')
def fonts(filename):
return static_file(filename, root='static/fonts')
# Re-Compile Sigma Model and Clean\Create tmp directory
clean_tmp()
compile.build(settings.sigma['model'])
# Custom Template Path and Run Server with Debug on
TEMPLATE_PATH.insert(0, "./templates/")
print "SigmaWeb Running At: http://%s:%s" % (settings.server['hostname'], settings.server['port'])
run(host=settings.server['hostname'], port=settings.server['port'], quiet=True)