- Python Web - Django Framework
- Django Framework - Overview
- Django Framework - Users
- Django Framework - Installation
- Django Framework - Creating Application
- Python Web - Flask Framework
- Python Web - Flask Framework
- Flask Framework - Creating URL Routing
- Flask Framework - Using Templates
- Python Web - Pyramid Framework
- Python Web - Pyramid Framework
- Pyramid Framework - Core Concepts
- Pyramid Framework - Creating Application
- Python Web - Dash Framework
- Python Web - Dash Framework
- Dash Framework - App Layout
- Dash Framework - HTML Component
- Dash Framework - Visualization
- Python Web - py4web Framework
- Python Web - py4Web Framework
- py4web Framework - Dashboard
- py4web Framework - Creating Application
- Python Web - Miscellaneous
- Python Web - Web2py Framework
- Python Web - Choosing a Better Framework
- Python Web Development Libraries Resources
- Python Web - Quick Guide
- Python Web - Useful Resources
- Python Web - Discussion
Pyramid Framework - Create Application
The simplest program we can think after installing pyramid framework to check if everything is working fine, is to run a simple Hello, World or Hello, Pyramid program.
Below is my pyramid Hello, Pyramid program on 8000 port number −
app.py
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello Pyramid!
')
if __name__ == '__main__':
with Configurator() as config:
config.add_route('hello', '/')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8000, app)
server.serve_forever()
Output
Running the simplest program: −
py app.py 127.0.0.1 - - [12/Mar/2026 20:03:57] "GET / HTTP/1.1" 200 23 127.0.0.1 - - [12/Mar/2026 20:03:57] "GET /favicon.ico HTTP/1.1" 404 164
Next, open http://localhost:8000/ in a browser, and you will see the Hello, Pyramid! Message as follows −
Explanation
The following is the explanation for above code −
Line no. 1-3
At the head of the file, we have import statements. The first line imports make_server function, which can create a simple web server when it is passed to an application. The second and third line import the configuration and Response function from pyramid. These functions are used to configure details and set parameters for the application and respond to requests, respectively.
Line no. 5-6
Now we have a function definition called hello_world. Implement view code that generates the response. A function that fulfils the requirement of a view is responsible for rendering the text that will be passed back to the requesting entity. In the above case, the function, when called, uses the Response function we imported earlier. This passes back a value that should be given to the client.
Line no. 8
if __name__ == __main__: Python is saying, Start here when running from the command line, rather than when this module is imported.
Line no. 9-11
In line no. 9, we create a variable called config out of the object created by the configurator function that we imported at the top of the program. Line 10 and 11 call the add_route and add_view method of this object. This method is used to define a view that can be used by the application. As we can see, we pass the hello_world function we defined earlier. This is where that function is actually incorporated as a view.
Line no. 12-14
In this, we actually create the WSGI application by calling the make_wsgi_app method of the config object. This uses the objects attributes, such as the view we added, to create an application. This application is then passed to the make_server function we imported in order to create an object that can launch a web server to serve our application. The last line launches this server.
Our hello world application is one of the simplest and easiest possible pyramid applications, configured imperatively. It is imperative because the full power of Python is available to us as we perform configuration tasks.
To summarize, Pyramid is an open source python web framework with a large and active community. This large community contributes towards making the python web framework popular and relevant. Pyramid web framework simplify and accelerate web application development by providing a set of robust features and tools.