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Ā
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']}"
- In lines 1ā2 we import Retica and Retica.Render.
- In line 3 we create a new instance of the server.
- In line 5 we create a new instance of the templator.
- 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])
- In lines 1ā2 we import your server fromĀ
app.py
Ā and theĀSockets
Ā module from Retica. - In line 4 we create a socket for the server at port 80.
- 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