paint-brush
Web Development in Python With the Retica Frameworkby@sushantshah
358 reads
358 reads

Web Development in Python With the Retica Framework

by Sushant ShahAugust 23rd, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Retica is a free and open-source python web framework and is available via the pip package manager. The framework comes with ReticaCLI which is a terminal-based tool that allows you to easily create a new project or run your existing projects. You can create as many endpoints as you want and customize them to suit your needs.

People Mentioned

Mention Thumbnail
featured image - Web Development in Python With the Retica Framework
Sushant Shah HackerNoon profile picture


Disclaimer: I am the developer of this framework.


Websites are a crucial part of any business. They are the foundation of any online business. Websites are what introduce people to your company and make it easier for them to find your business. However, to build a website, you need to know how to. Today, I will show you how to make a website in python using the Retica framework. This is the framework I use to build my websites and it is free and open-source.


Installing Retica

Before Installing Retica, it is recommended to create a virtual environment for your project. Create a virtual environment using the following command:


$~ python3 -m pip install --upgrade virtualenv 
$~ python3 -m venv env_name
$~ source env_name/bin/activate


Retica is available via the pip package manager.


$~ pip install retica 


If you don’t have pip installed, you can install it by running:


$~ python -m ensurepip —upgrade


Creating a New Retica Project

The Retica framework comes with ReticaCLI which is a terminal-based tool that allows you to easily create a new project or run your existing projects.


To Create A New Retica Project, run:


$~ retica create
Project Name: ProjectName #Use '.' for using the current directory.
Templates Folder: templates #Jinja Templates Folder.
Plugins Folder: plugins #Default Folder To Store Plugins.
Import Frontend Libraries? (y/n): #To Be Implemented.
Creating project...


The Folder Structure:


ProjectName/
  |- templates/
  |- plugins/
  |- app.py
  |- run.py

Exploring app.py

import Retica
import Retica.Render
retica = Retica.Server(__name__)

templator = Retica.Render.TemplateRender(retica,template_dir="templates")

@retica.create_endpoint("/hello/{name}")
def index(request: Retica.Request.request, response: Retica.Response.response, **data):
    response.body = f"Hello {data['name']}"


  1. In lines 1–2 we import Retica and Retica.Render.
  2. In line 3 we create a new instance of the server.
  3. In line 5 we create a new instance of the templator.
  4. In lines 7–9 we create an endpoint for the server at /hello/{name}.This is a dynamic URL. Here {name} is a placeholder for data and the value accessible from the data dictionary.

Exploring run.py

from app import retica
from Retica import Sockets

http_socket = Sockets.HTTP_Socket(Sockets.gethostname(), 80)

if __name__ == "__main__":
    retica.run([http_socket])


  1. In lines 1–2 we import your server from app.py and the Sockets module from Retica.
  2. In line 4 we create a socket for the server at port 80.
  3. In lines 6–7 we call run() on our server instance by passing the array of sockets.


As an alternative to using this file, you can also run $~ retica run to start the server directly from the command line.


You can create as many endpoints as you want and customize them to suit your needs. I will soon cover Jinja templating, Plugin creation, and an easy sample project.


Also Published here