Open In App

Python Pyramid – Creating A Project

This project is a dynamic web application built on the powerful Python Pyramid framework. In this, we’ll go through the comprehensive overview of the prerequisites you should have before diving into Pyramid, as well as the essential steps to get started with this powerful web framework. Pyramid enables programmers to create web applications of various sizes, from modestly sized side projects to expansive business systems. and we’ll get a look at how to start with the pyramid framework.

Prerequisites

Why should we use Pyramid?

Python Pyramid is a flexible web framework with many benefits, making it a fantastic option for many different web development projects. In the python, there are many different frameworks available for web development. Pyramid is one such framework that stands out for its ease of use, adaptability and scalability. Here are several justifications for considering Pyramid:



Pyrmaid Installation

Step 1 : Make sure Python is set up on the machine or From the Python website, we can get the most recent version. To check python installed or not run this command

>> python --version

[this command is use to check the current version of the python which is installed in the machine]



check python installation

Step 2 : It’s a good practice to create a virtual environment for your project to manage dependencies and isolate your project’s environment from the system-wide Python packages. To create a virtual environment, and activate it, please follow the command…

>> python -m venv myenv

[this command is use to create a new virtual invironment with the name of myenv(name can be change)]

create a virtual environment

     >> myenv\Scripts\activate

[this command is use to activate the virtual invironment which is previously created with the name of myenv]

activating virtual invironment

Step 3 : To Install the Pyramid framework Run the following command….

>> pip install pyramid

[the above command is use to install the pyramid framework into the machine]

to install pyramid

Step 4 : another tool name cookiecutter and waitress is required so to install this follow the command…

>> pip install cookiecutter waitress

[this command is used to install some other requirement for building the pyramid project.]

installing cookiecutter

Step 5 : now we have to create a new pyramid project. So to do this write that command…..

>> cookiecutter gh:Pylons/pyramid-cookiecutter-starter

[this command is use to create a fresh new pyramid project] And then choose appropriate options such as project name, template language and backend.

creating the project

Now the project has been created. then now navigate to project folder and install the dependencies by running this command….

>> pip install -e .

[this command is used to install all the required dependencies to start with the pyramid project]

installing project dependencies

Now all the reuired dependencies installed for the pyramid project. now the project is ready to serve.

Step 6 : To run the development server follow this command.

>> pserve development.ini

[the mention command is use to start the pyramid development server to run the project]

running the project

The project runs successfully to see that open the serving URL(http://127.0.0.1:6543) and open it on the browser.

Output:

project output

Note:

HTML – firstproject/templates/mytemplate.jinja2

firstproject/templates/layout.jinja2

CSS- firstproject/static/theme.css

Article Tags :