A framework that let's you compose websites in Python with ease!

Related tags

Web FrameworksPerry
Overview

Perry

Perry <= A framework that let's you compose websites in Python with ease!

Perry works similar to Qt and Flutter, allowing you to create component collections. Say you want to create a div with some text and an image. To do that you'd first need to create the page:

from Perry import component, pageView, serve, Composite

Let's break it down:

  • Component - A given element that can be added anywhere on the page
  • pageView - Creates a page with a route for us, we can load styles, JS and other things into it by using the 'styles' argument
  • Serve - A Flask based micro-server for Perry
  • Composite - The most important part! This tells our components to build themselves recursively as well as creating the skeleton, route and debugging info.

Now let's create the page

Homepage = component(pageView, _Inherit = True)
# a pageView is also a component, but inherits different functionality

# Assign page contents
Homepage <= {
  'title': 'Home', # Title of the page 
  'path':'',       # Route on the webserver, no need to include the starting /
  'styles': [bootstrap], # Styles and other components, here we load bootstrap which is included in Extras
  'DOM': pageView.DOM,   # DOM, not yet implemented but worth using in case you want to upgrade to a newer verion of Perry later
  'components': HomepageContents # A ComponentSource with our elements
}

This page will just show up as an error as we haven't yet created our component source! This can be done through importing ComponentSource

HomepageContents = ComponentSource(
  DIV(
    Label('Hello World!', 'h1'),
    Card(
        Image('Image URL'),
        CardText('Sample Text which has attributes for bootstrap cards', 'p')   
    ),
    Label('Good bye!', 'h1')
  )
)

You'll get something like this. The trailing comment is used for debugging

<body>
   <!-- Components --->  
   <div id="" class="">
      <h1 id=""> Hello World! </h1>
      <!-- Component: <Label id:0x7f398481c910>---> 
      <div style="width: 18rem;" id="" class="card, ">
         <div class="card-body">
            <img src="Image URL" id="style=''">
            <!-- Component: <Image id:0x7f398481c9d0>---> 
            <p id="class='card-text'"> Sample Text which has attributes for bootstrap cards </p>
            <!-- Component: <BootstrapCardText id:0x7f398481ca60>---> 
         </div>
      </div>
      <!-- Component: <BootrstrapCard cclass:None id:0x7f398481cb20>---> 
      <h1 id=""> Good bye! </h1>
      <!-- Component: <Label id:0x7f398481cbe0>---> 
   </div>
   <!-- Component: <DIV cclass:None id:0x7f398481cca0>--->  
   <p id=""> Running on Perry v0.9 with Debug Mode on! </p>
   <!-- Component: <Label id:0x7f3984885d90>--->
   <!-- End of Components --->
</body>

Custom Element Bundles and Styling

Want to bundle together multiple elements and create a universal one? That's easy to do!

OurCoolNewElement = DIV(
    Label('Hello, I have custom stuff!', 'h1', id = 'CoolTitle'),
    cclass = 'NewElement'
)
# Let's give it some style
ourCustomStyle = style()
ourCustomStyle <= {
  'author':'HUSKI3',
  'source':'Local-made ;)'
  'ctype':'css',
  'css' : '''
  .NewElement {
    color: white;
    background: black;
  }
  '''}
# And now add it to the components
HomepageContents = ComponentSource(
  DIV(
    Label('Hello World!', 'h1'),
    OurCoolNewElement , # <--- here
    Label('Good bye!', 'h1')
  )
)

You'll need to load the style when defining the homepage contents!

Homepage <= {
  ...,
  'styles': [some, styles, ourCustomStyle],
  ...
}

Adding JS Support

At the moment JS doesn't have direct support through built in components, but you can use JQueryEngine and JQueryEngineStrapper from Extras.

# First we create the component with JQuery, give it a pageView to wrap around (WIP)
js = JQueryEngine(pageView, cid = 'coolscript')
# Now you load in the script, it can either be a string or a read from file
js <= ( open('PerryApp/coolscript.js','r').read() )
# To load it in, you need to add JQueryEngineStrapper to the styles of the page and add the js component to the components
HomepageContents.add( js )

Serving pages with Flask

In Perry you always serve pages as a Composite collection, this way they are built and then loaded on Flask on the specified routes.

# Serve our pages as a composite collection
serve <= Composite(Homepage, About, OtherPage, debug = True)
Owner
Linkus
Back-end Dev. Forma is the best. Check out @RocKing1001 for his cool projects!
Linkus
A Python package to easily create APIs in Python.

API_Easy An Python Package for easily create APIs in Python pip install easy-api-builder Requiremnets: = python 3.6 Required modules -- Flask Docume

Envyre-Coding 2 Jan 04, 2022
REST API framework designed for human beings

Eve Eve is an open source Python REST API framework designed for human beings. It allows to effortlessly build and deploy highly customizable, fully f

eve 6.6k Jan 07, 2023
Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints.

Flask Sugar is a web framework for building APIs with Flask, Pydantic and Python 3.6+ type hints. check parameters and generate API documents automatically. Flask Sugar是一个基于flask,pyddantic,类型注解的API框架

162 Dec 26, 2022
WAZO REST API for the call management of the C4 infrastructure

wazo-router-calld wazo-router-calld provides REST API for the C4 infrastructure. Installing wazo-router-calld The server is already provided as a part

Wazo Platform 4 Dec 21, 2022
Dazzler is a Python async UI/Web framework built with aiohttp and react.

Dazzler is a Python async UI/Web framework built with aiohttp and react. Create dazzling fast pages with a layout of Python components and bindings to update from the backend.

Philippe Duval 17 Oct 18, 2022
JustPy is an object-oriented, component based, high-level Python Web Framework

JustPy Docs and Tutorials Introduction JustPy is an object-oriented, component based, high-level Python Web Framework that requires no front-en

927 Jan 08, 2023
Containers And REST APIs Workshop

Containers & REST APIs Workshop Containers vs Virtual Machines Ferramentas Podman: https://podman.io/ Docker: https://www.docker.com/ IBM CLI: https:/

Vanderlei Munhoz 8 Dec 16, 2021
Dockerized web application on Starlite, SQLAlchemy1.4, PostgreSQL

Production-ready dockerized async REST API on Starlite with SQLAlchemy and PostgreSQL

Artur Shiriev 10 Jan 03, 2023
FastAPI framework, high performance, easy to learn, fast to code, ready for production

FastAPI framework, high performance, easy to learn, fast to code, ready for production Documentation: https://fastapi.tiangolo.com Source Code: https:

Sebastián Ramírez 53k Jan 02, 2023
Pyramid - A Python web framework

Pyramid Pyramid is a small, fast, down-to-earth, open source Python web framework. It makes real-world web application development and deployment more

Pylons Project 3.7k Dec 30, 2022
Appier is an object-oriented Python web framework built for super fast app development.

Joyful Python Web App development Appier is an object-oriented Python web framework built for super fast app development. It's as lightweight as possi

Hive Solutions 122 Dec 22, 2022
web.py is a web framework for python that is as simple as it is powerful.

web.py is a web framework for Python that is as simple as it is powerful. Visit http://webpy.org/ for more information. The latest stable release 0.62

5.8k Dec 30, 2022
bottle.py is a fast and simple micro-framework for python web-applications.

Bottle: Python Web Framework Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module a

Bottle Micro Web Framework 7.8k Dec 31, 2022
A microservice written in Python detecting nudity in images/videos

py-nudec py-nudec (python nude detector) is a microservice, which scans all the images and videos from the multipart/form-data request payload and sen

Michael Grigoryan 8 Jul 09, 2022
Asita is a web application framework for python.

What is Asita ? Asita is a web application framework for python. It is designed to be easy to use and be more easy for javascript users to use python

Mattéo 4 Nov 16, 2021
A Flask API REST to access words' definition

A Flask API to access words' definitions

Pablo Emídio S.S 9 Jul 22, 2022
A simple todo app using flask and sqlachemy

TODO app This is a simple TODO app made using Flask. Packages used: DoodleCSS Special thanks to Chris McCormick (@mccrmx) :) Flask Flask-SQLAlchemy Fl

Lenin 1 Dec 26, 2021
Ape is a framework for Web3 Python applications and smart contracts, with advanced functionality for testing, deployment, and on-chain interactions.

Ape Framework Ape is a framework for Web3 Python applications and smart contracts, with advanced functionality for testing, deployment, and on-chain i

ApeWorX Ltd. 552 Dec 30, 2022
The comprehensive WSGI web application library.

Werkzeug werkzeug German noun: "tool". Etymology: werk ("work"), zeug ("stuff") Werkzeug is a comprehensive WSGI web application library. It began as

The Pallets Projects 6.2k Jan 01, 2023
Bablyon 🐍 A small ASGI web framework

A small ASGI web framework that you can make asynchronous web applications using uvicorn with using few lines of code

xArty 8 Dec 07, 2021