Code Monkey home page Code Monkey logo

retica's Introduction

Retica Banner

Documentation Status:

Documentation Status

Contact Us:

WhatsApp Discord Twitter

The Retica Backend Server

Retica Is A Performant, Easy To Use Web Server Based On Python With HTTPS & Plugins Support.

Retica V/S Flask

The Following Graph Shows A Performane Comparision Between Flask & Retica.

  1. Total 5,000 Requests with 5 Concurrent Connections
  2. Total 20,000 Requests with 20 Concurrent Connections

Flask V/S Retica

Installing Retica

The easiest way to install Retica is to use the pip command line tool.

$~ pip install retica

Creating A Retica Server

Once you have installed Retica, you can import it into your Python environment. The server class is used to create a server, in which you can add endpoints(locations) and open HTTP(s) ports.

import Retica
retica = Retica.Server(__name__)

Creating An Endpoint

Endpoints are functions that are assigned to a location and are called when a request is made to that location.

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

Creating A Socket

Sockets are used to open a server port that listens for incoming connections. The server will listen on the specified port and host. Sockets can use 2 protocols:

  1. HTTP
  2. HTTPS (Certificate & key files are required)
  • You can also create your own protocols(In Development).
http_socket = Retica.Sockets.HTTP_Socket("localhost", 80)
https_socket = Retica.Sockets.HTTPS_Socket("localhost", 443, "cert.pem", "key.pem")

Running the Server

To run the server, you must call the run method on the server. An array of sockets should be passed in as an argument.

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

Boilerplate

This is the boilerplate code that you will need to create your own server.

import Retica
retica = Retica.Server(__name__)

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

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.