from
wsgiref.simple_server
import
make_server
from
pyramid.response
import
Response
from
pyramid.view
import
view_config
from
pyramid.config
import
Configurator
employees
=
[
{
"id"
:
1
,
"name"
:
"Sameer"
,
"department"
:
"Sales"
,
"mobile"
:
6756453456
,
"salary"
:
75000
},
{
"id"
:
2
,
"name"
:
"Rahul"
,
"department"
:
"Content"
,
"mobile"
:
8978675678
,
"salary"
:
50000
},
{
"id"
:
3
,
"name"
:
"Mahesh"
,
"department"
:
"Marketting"
,
"mobile"
:
7989881110
,
"salary"
:
30000
},
]
@view_config
(route_name
=
'index'
, renderer
=
'form.html'
)
def
index(request):
return
{}
@view_config
(route_name
=
'employees'
, renderer
=
'marklist.html'
)
def
add(request):
employee
=
{
'id'
:request.params[
'id'
],
'name'
:request.params[
'name'
],
'department'
:request.params[
'department'
],
'mobile'
:request.params[
'mobile'
],
'salary'
:
int
(request.params[
'salary'
])}
employees.append(employee)
return
{
'employees'
:employees}
if
__name__
=
=
'__main__'
:
with Configurator() as config:
config.include(
'pyramid_jinja2'
)
config.add_jinja2_renderer(
".html"
)
config.add_route(
'index'
,
'/'
)
config.add_route(
'employees'
,
'/employees'
)
config.scan()
app
=
config.make_wsgi_app()
server
=
make_server(
'0.0.0.0'
,
5000
, app)
server.serve_forever()