Pyramid is a lightweight python web framework following MVC architectural pattern. In this article, we will set up a web application and API using Pyramid.

Pyramid is a suitable framework for large scale MVC applications and it comes with flexible bootstrapping tools.

Cornice, a library from Mozilla, makes it easy to develop RESTful web services with pyramid.


First we create a virtual environment which helps us in separating project specific python packages installations from other projects. After activating the virtual environment, we install pyramid framework using command:

pip install pyramid

Create models

We create a file with a class Note which maps to the data table storing all the values of notes.

# pyramidapp/models.pyclass Note(Base):
__tablename__ = 'Note'
id = Column(Integer, primary_key=True)
title = Column(Text)
description = Column(Text)
create_at = Column(Text)
create_by = Column(Text)
priority = Column(Integer)
def __init__(self, title, description, create_at ,create_by, priority):
self.title = title
self.description = description
self.create_at = create_at
self.create_by = create_by
self.priority = priority
def from_json(cls, data):
return cls(**data)
def to_json(self):
to_serialize = ['id', 'title', 'description', 'create_at', 'create_by', 'priority']
d = {}
for attr_name in to_serialize:
d[attr_name] = getattr(self, attr_name)
return d

To read more click on


Written by


We deliver excellent apps

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade