-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyramid.py
45 lines (41 loc) · 1.38 KB
/
pyramid.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
from wsgiref.simple_server import make_server
from jinja2 import Environment, FileSystemLoader
from pyramid.config import Configurator
from pyramid.response import Response
includes = [
'app.js',
'react.js',
'leaflet.js',
'D3.js',
'moment.js',
'math.js',
'main.css',
'bootstrap.css',
'normalize.css',
]
environment = Environment(loader = FileSystemLoader('templates'))
css = []
js = []
def adding():
for i in includes:
if(i.split('.')[1] == 'css'):
css.append(i)
else:
js.append(i)
response = self.app(environ, start_response).decode()
return (response).encode()
def Index(request):
return Response(enviroment.get_template('/index.html').render({'styles':css,'scripts':js}))
def AboutMe(request):
return Response(enviroment.get_template('/about/aboutme.html').render({'styles':css,'scripts':js}))
def app():
conf = Configurator()
conf.add_route('Index', '/index.html')
conf.add_view(Index, route_name='Index')
conf.add_route('AboutMe', '/about/aboutme.html')
conf.add_view(AboutMe, route_name='AboutMe')
return conf.make_wsgi_app()
if __name__ == '__main__':
adding()
ap=app()
server = make_server('localhost', 8000, ap)