Python‎ > ‎

pyramid


Introduction
The pyramid is high-level python framework for development of web apps. It is simple, fast, and highly documented. 

Examples
The pyramid returns with the if statement execution after testing equation of the values of two variable. 
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

def test(request):
    x=range(1,0)
    y=13
    if y in x:
        return Response('y is in x')
    else:
        return Response('y is not in x')

def main():
    config = Configurator()
    config.add_route('index', '/')                        
    config.add_view(test, route_name='index')
    app = config.make_wsgi_app()
    return app

if __name__ == '__main__':
    app = main()
    server = make_server('0.0.0.0', 1000, app)
    print ('Starting up server on http://localhost:1000')
    server.serve_forever()





The html code are integrated inside the pyramid.response.Response().
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response

def html(request):
    return Response(
        '<a href="http://www.pythonlake.com/">Python Lake</a>'
        '<hr>'
        '<a href="http://www.pythonlake.com/aboutus">About us</a>'
        '<hr>'
        '<a href="http://www.pythonlake.com/appointment">Appointment</a>'
        '<hr>'
        '<a href="http://www.pythonlake.com/contactus">Contact us</a>')
    
if __name__ == '__main__':
    config = Configurator()
    config.add_route('links', '/')
    config.add_view(html, route_name='links')
    app = config.make_wsgi_app()
    server = make_server('0.0.0.0', 1000, app)
    server.serve_forever()





Subpages (27): View All
Comments