-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb6.py
51 lines (44 loc) · 1.22 KB
/
web6.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
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from webob import Request, Response
from jinja2 import Environment, FileSystemLoader
items = [
'app.js',
'react.js',
'leaflet.js',
'D3.js',
'moment.js',
'math.js',
'main.css',
'bootstrap.css',
'normalize.css',
]
js = []
css = []
for item in items:
dividedOne, dividedTwo = item.split('.')
if dividedTwo == 'js':
js.append(item)
elif dividedTwo == 'css':
css.append(item)
env = Environment(loader=FileSystemLoader('.'))
# Вывод index.html
def index(request):
template = env.get_template('index.html')
return Response(template.render(scripts=js, styles=css))
# Вывод aboutme.html
def about(request):
template = env.get_template('about/aboutme.html')
return Response(template.render(scripts=js, styles=css))
def main():
config = Configurator()
config.add_route('index', '/')
config.add_view(index, route_name='index')
config.add_route('about', '/about')
config.add_view(about, route_name='about')
app = config.make_wsgi_app()
return app
if __name__ == '__main__':
app = main()
make_server('0.0.0.0', 80, app).serve_forever()