JustPy is an object-oriented, component based, high-level Python Web Framework

Overview

JustPy

JustPy Docs and Tutorials

Introduction

JustPy is an object-oriented, component based, high-level Python Web Framework that requires no front-end programming. With a few lines of only Python code, you can create interactive websites without any JavaScript programming. JustPy can also be used to create graphic user interfaces for Python programs.

Unlike other web frameworks, JustPy has no front-end/back-end distinction. All programming is done on the back-end allowing a simpler, more productive, and more Pythonic web development experience. JustPy removes the front-end/back-end distinction by intercepting the relevant events on the front-end and sending them to the back-end to be processed.

In JustPy, elements on the web page are instances of component classes. A component in JustPy is a Python class that allows you to instantiate reusable custom elements whose functionality and design is encapsulated away from the rest of your code.

Custom components can be created using other components as building blocks. Out of the box, JustPy comes with support for HTML and SVG components as well as more complex components such as charts and grids. It also supports most of the components and the functionality of the Quasar library of Material Design 2.0 components.

JustPy encourages creating your own components and reusing them in different projects (and, if applicable, sharing these components with others).

JustPy supports visualization using matplotlib and Highcharts.

JustPy integrates nicely with pandas and simplifies building web sites based on pandas analysis. JustPy comes with a pandas extension that makes it simple to create interactive charts and grids from pandas data structures.

For updates and news please follow the JustPy Twitter account

Hello World!

import justpy as jp

def hello_world():
    wp = jp.WebPage()
    d = jp.Div(text='Hello world!')
    wp.add(d)
    return wp
    
jp.justpy(hello_world)

The program above activates a web server that returns a web page with 'Hello world!' for any request. Locally, you would direct your browser to http://127.0.0.1:8000 or http://localhost:8000/ or to see the result.

Here is a slightly modified version in which 'Hello world!' changes to 'I was clicked!' when it is clicked.

import justpy as jp

def my_click(self, msg):
    self.text = 'I was clicked!'

def hello_world():
    wp = jp.WebPage()
    d = jp.Div(text='Hello world!')
    d.on('click', my_click)
    wp.add(d)
    return wp

jp.justpy(hello_world)

Many other examples can be found in the tutorial

Under the Hood

JustPy's backend is built using:

JustPy's frontend (which is transparent to JustPy developers) is built using:

  • Vue.js - "The Progressive JavaScript Framework"

The way JustPy removes the frontend/backend distinction is by intercepting the relevant events on the frontend and sending them to the backend to be processed.

License

Apache License, Version 2.0

Copyright (c) 2019, Eliezer Mintz

Comments
  • hot reloading (refresh) of page when source is modified

    hot reloading (refresh) of page when source is modified

    The current usual workflow is to a) modify the code, 2) stop the justpy service, 3) restart the service and finally reload the webpage. I was wondering if it is possible to bypass/short circuit this flow. Is it possible the page gets rendered automatically when the source is modified?

    Also, thanks for the great package :).

    enhancement 
    opened by sandeep-gh 29
  • Would there be any way to execute a function after x seconds of inactivity?

    Would there be any way to execute a function after x seconds of inactivity?

    Would there be any way to execute a function after x seconds of inactivity?

    For example, a timer that would start after the mouse has stopped moving and after x number of seconds of inactivity a function is executed.

    Originally posted by @knoxvilledatabase in https://github.com/elimintz/justpy/issues/59#issuecomment-622236707

    opened by elimintz 23
  • demjeson install cannot be done since setuptools upgrade, so neither justpy can.

    demjeson install cannot be done since setuptools upgrade, so neither justpy can.

    Today on a new deploy I did :

    pip3 install justpy
    

    but ends up failing because:

    ERROR: Cannot install justpy==0.0.5, justpy==0.0.6, justpy==0.0.7, justpy==0.0.8, justpy==0.0.9, justpy==0.1.0, justpy==0.1.1, justpy==0.1.2, justpy==0.1.3, justpy==0.1.4 and justpy==0.1.5 because these package versions have conflicting dependencies.
    
    The conflict is caused by:
        justpy 0.1.5 depends on demjson>=2.2.4
        justpy 0.1.4 depends on demjson>=2.2.4
        justpy 0.1.3 depends on demjson>=2.2.4
        justpy 0.1.2 depends on demjson>=2.2.4
        justpy 0.1.1 depends on demjson>=2.2.4
        justpy 0.1.0 depends on demjson>=2.2.4
        justpy 0.0.9 depends on demjson>=2.2.4
        justpy 0.0.8 depends on demjson>=2.2.4
        justpy 0.0.7 depends on demjson>=2.2.4
        justpy 0.0.6 depends on demjson>=2.2.4
        justpy 0.0.5 depends on demjson>=2.2.4
    
    To fix this you could try to:
    1. loosen the range of package versions you've specified
    2. remove package versions to allow pip attempt to solve the dependency conflict
    
    

    it is an open issue at demjson repo:

    https://github.com/dmeranda/demjson/issues/40

    Downgrading to setuptools 57.5.0 it des not work, it installs but while doing:

    import justpy
    

    gives:

    import justpy
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/data/giodegas/dev/AQ2009/myenv/lib/python3.8/site-packages/justpy/__init__.py", line 1, in <module>
        from .justpy import *
      File "/data/giodegas/dev/AQ2009/myenv/lib/python3.8/site-packages/justpy/justpy.py", line 13, in <module>
        from .chartcomponents import *
      File "/data/giodegas/dev/AQ2009/myenv/lib/python3.8/site-packages/justpy/chartcomponents.py", line 2, in <module>
        import demjson
      File "/data/giodegas/dev/AQ2009/temp/demjson/demjson.py", line 645
        class json_int( (1L).__class__ ):    # Have to specify base this way to satisfy 2to3
                          ^
    SyntaxError: invalid syntax
    
    

    @elimintz what can I do now? Thank you for your support.

    bug 
    opened by giodegas 18
  • How to use AgGrid API

    How to use AgGrid API

    https://www.ag-grid.com/javascript-grid-data-update-transactions/ hi i'm looking for a guide to use the grid API applyTransaction(transaction) to correctly update the data in my grid. i read your example :https://justpy.io/grids_tutorial/grid_api/ but in this example the functions: self.grid.run_api('selectAll()', msg.page) and self.grid.run_api('deselectAll()', msg.page) don't need any parameter. applyTransaction(transaction) instead need the transaction object, can you show me how to pass it correctly? thanks for the help

    enhancement 
    opened by Killitz 18
  • How to broadcast wp.update() to all clients on a certain page?

    How to broadcast wp.update() to all clients on a certain page?

    We would like to request all clients to reload a page when a user makes a specific change on our database but we don't want to put the entire page in a shared component because it's a lot of data.

    Would you have any ideas for how to solve this?

    opened by knoxvilledatabase 18
  • Internet access required for client?

    Internet access required for client?

    I have deployed a web page on my intranet using Justpy (which is great by the way!), but I have a couple of clients that do not have access internet access, and they cannot display the web page, as soon as I enable internet access they are able to display the page correctly, but I cannot leave internet access enabled.

    Any work around or setting I can modify to make a justpy page work without internet access?

    opened by samesand 16
  • Justpy seems to swallow exceptions in event handlers

    Justpy seems to swallow exceptions in event handlers

    I'd made a programming error in a button handler. However no exception appeared and the program kept running (without the intended behaviour obviously). Also in the PyCharm no exception was caught.

    BTW JustPy is a godsend. Please promote it more!

    opened by mjmare 15
  • Signature Pad Component

    Signature Pad Component

    One of the apps I'm replacing with JustPy requires a signature pad component. I noticed that there is already a Vue Signature Pad Component (https://github.com/neighborhood999/vue-signature-pad). Is this something you would be interested in having within the JustPy framework?

    enhancement 
    opened by knoxvilledatabase 15
  • Input component shows input chars appearing and disappearing as user types

    Input component shows input chars appearing and disappearing as user types

    It appears background input checkers are sometimes backspacing after the user enters in a char, then it appears again. This happens when typing moderately fast. It sometimes even misses capturing the user input altogether.

    This is very disconcerting. Is there some way of affecting this behavior?

    opened by DeviceNut 14
  • url_for functionality for justpy routing using starlette

    url_for functionality for justpy routing using starlette

    @sandeep-gh in #389 suggested that the following Unit Test should work:

    '''
    Created on 2022-08-30
    
    @author: 
    @author: wf
    '''
    import justpy as jp
    from starlette.testclient import TestClient
    
    @jp.SetRoute("/bye", name = "bye")
    def bye_function(_request):
        wp = jp.WebPage()
        wp.add(jp.P(text='Hello there!', classes='text-5xl m-2'))
        return wp
    
    @jp.SetRoute("/hello", name = "hello")
    def hello_function(request):
        wp = jp.WebPage()
        wp.add(jp.P(text='Hello there!', classes='text-5xl m-2'))
        print("request  = ", request.url_for("bye"))
        return wp
    
    app = jp.app
    client = TestClient(app)
    client.get("/hello")
    
    enhancement core 
    opened by WolfgangFahl 13
  • dependency with h11 causes wrong behaviour of justpy apps

    dependency with h11 causes wrong behaviour of justpy apps

    Since few days, I got a strange behavior from a justpy application. It starts looping over the main function, with this error at the console:

    WARNING:  Unsupported upgrade request.
    WARNING h11_impl: Unsupported upgrade request.
    

    I guess is due to some changes in the underlining library h11.

    What can I do to downgrade to the previous stable situation?

    Thank's.

    opened by giodegas 13
  • PlainTextResponse(

    PlainTextResponse("Bad Session") not executed

    First of all, I apologize if the way/form of reporting a possible bug is not correct: it's the first time I've done it.

    In this Def (located in justpy_app.py):

    def handle_session_cookie(self,request) -> typing.Union[bool, Response]:
            # Handle web requests
            session_cookie = request.cookies.get(SESSION_COOKIE_NAME)   
            #print(cookie_signer.unsign(session_cookie).decode("utf-8"))
            new_cookie=None
            if SESSIONS:
                new_cookie = False
                if session_cookie:
                    try:
                        session_id = cookie_signer.unsign(session_cookie).decode("utf-8")
                    except:
                        return PlainTextResponse("Bad Session") <==============
                    request.state.session_id = session_id
                    request.session_id = session_id
                else:
                    # Create new session_id
                    request.state.session_id = str(uuid.uuid4().hex)
                    request.session_id = request.state.session_id
                    new_cookie = True
                    logging.debug(f"New session_id created: {request.session_id}")
            return new_cookie
    

    If you try to have session_id, in this Def, if you need the case in which JustPy should return an error in the session through the writing "Bad Session", now return this error:

    AttributeError: 'Request' object has no attribute 'session_id'

    bug 
    opened by Phonix88 2
  • Move example resources to example folder

    Move example resources to example folder

    currently a few resources are on the parent folder of the project

    • https://github.com/justpy-org/justpy/blob/master/papillon.jpg
    • https://github.com/justpy-org/justpy/tree/master/components

    but are only used by some examples. These resources should be moved to the examples folder or to the example itself.

    For the static_test the problem of the static folder in the context of the demo_browser needs to be solved. https://github.com/justpy-org/justpy/blob/7e49c1dc69c490cc17a47f66d0ccad329c7383a3/examples/tutorial/static/static_test.py#L4-L7

    demo 
    opened by tholzheim 0
  • url_for in templates/main.html causes blocked loading mixed active content error

    url_for in templates/main.html causes blocked loading mixed active content error

    The url_for in this template

    https://github.com/justpy-org/justpy/blob/48c3e857461ebeeea05ac65ebe7f72ff49ae63af/justpy/templates/main.html

    resulted in this blocked loading mixed active content error

    https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content#warnings_in_firefox_web_console

    which was caused by

    https://github.com/encode/starlette-example/issues/6

    but seemed to be fixed in

    https://github.com/encode/uvicorn/issues/369

    However, this is still not resolved in JustPy which make an advanced component like this one

    https://justpy.io/tutorial/advanced_components/#fullcalendar-example

    unable to be deployed in public server.

    Is there a way to make url_for return an https instead of http?

    bug 
    opened by kimgiftww 1
  • Add support for tree data in aggrid

    Add support for tree data in aggrid

    Add support for tree-styled data in aggrid. See here for aggrid documentation of the feature.

    I think we just need to update the logic here -> https://github.com/justpy-org/justpy/blob/master/justpy/templates/js/vue/aggrid.js#L18. The following code should work,

    if (key==='getDataPath')) { eval('def[key] = ' + def[key]); }

    opened by bigfatwhale 0
  • model and data attribute globally on wp

    model and data attribute globally on wp

    the tutorial https://justpy.io/tutorial/model_and_data/ introduces the model and data attribute and shows how to globally access data via wp. This should not be encouraged any more. The opposite is the case so the hint

    Note: Any element, a Div for example, may have a data attribute and be used in a model attribute, not just a WebPage.

    currently is misleading. There should be a recommendation to allways keep the data attribute in a local scope see e.g. https://github.com/WolfgangFahl/pyJustpyWidgets/issues/15 and the example below which implement proper information hiding.

    class SimpleCheckbox(jp.Div):
        """
        a simple Checkbox
        """ 
        def __init__(self,a,labelText,**kwargs):
            """
            create a simple checkbox with the given label
            """
            jp.Div.__init__(self,a=a,classes="col-1",data={'checked': False})
            self.checkbox=jp.Input(a=self,type="checkbox",classes="form-check-input", model=[self, 'checked'],**kwargs)
            self.label=jp.Label(a=self,text=labelText)
            
        def check(self,checked:bool):
            self.data["checked"]=checked
            
        def isChecked(self)->bool:
            return self.data["checked"]
    
    bug documentation 
    opened by WolfgangFahl 0
Releases(v0.12.0)
The source code to the Midnight project

MidnightSniper Started: 24/08/2021 Ended: 24/10/2021 What? This is the source code to a project developed to snipe minecraft names Why release? The ad

Kami 2 Dec 03, 2021
The little ASGI framework that shines. ?

✨ The little ASGI framework that shines. ✨ Documentation: https://www.starlette.io/ Community: https://discuss.encode.io/c/starlette Starlette Starlet

Encode 7.7k Jan 01, 2023
The lightning-fast ASGI server. ?

The lightning-fast ASGI server. Documentation: https://www.uvicorn.org Community: https://discuss.encode.io/c/uvicorn Requirements: Python 3.6+ (For P

Encode 6k Jan 03, 2023
The Python micro framework for building web applications.

Flask Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to co

The Pallets Projects 61.5k Jan 06, 2023
A python application to log QSOs directly to QRZ.com from the command line

qrzlogger This script is a QRZ.com command line QSO logger. It does the following: asks the user for a call sign displays available call sign info pul

Michael Clemens 15 Jul 16, 2021
Djask is a web framework for python which stands on the top of Flask and will be as powerful as Django.

Djask is a web framework for python which stands on the top of Flask and will be as powerful as Django.

Andy Zhou 27 Sep 08, 2022
Restful API framework wrapped around MongoEngine

Flask-MongoRest A Restful API framework wrapped around MongoEngine. Setup from flask import Flask from flask_mongoengine import MongoEngine from flask

Close 525 Jan 01, 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
O SnakeG é um WSGI feito para suprir necessidadades de perfomance e segurança.

SnakeG O SnakeG é um WSGI feito para suprir necessidadades de perfomance e segurança. Veja o que o SnakeG possui: Multiprocessamento de requisições HT

Jaedson Silva 1 Jul 02, 2022
Swagger/OpenAPI First framework for Python on top of Flask with automatic endpoint validation & OAuth2 support

Connexion Connexion is a framework that automagically handles HTTP requests based on OpenAPI Specification (formerly known as Swagger Spec) of your AP

Zalando SE 4.2k Jan 07, 2023
An effective, simple, and async security library for the Sanic framework.

Sanic Security An effective, simple, and async security library for the Sanic framework. Table of Contents About the Project Getting Started Prerequis

Sunset Dev 72 Nov 30, 2022
Daniel Vaz Gaspar 4k Jan 08, 2023
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
Flask + Docker + Nginx + Gunicorn + MySQL + Factory Method Pattern

This Flask project is reusable and also an example of how to merge Flask, Docker, Nginx, Gunicorn, MySQL, new: Flask-RESTX, Factory Method design pattern, and other optional dependencies such as Dyna

Facundo Padilla 19 Jul 23, 2022
Python Wrapper for interacting with the Flutterwave API

Python Flutterwave Description Python Wrapper for interacting with the Flutterwa

William Otieno 32 Dec 14, 2022
Asynchronous HTTP client/server framework for asyncio and Python

Async http client/server framework Key Features Supports both client and server side of HTTP protocol. Supports both client and server Web-Sockets out

aio-libs 13.2k Jan 05, 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
The web framework for inventors

Emmett is a full-stack Python web framework designed with simplicity in mind. The aim of Emmett is to be clearly understandable, easy to be learned an

Emmett 796 Dec 26, 2022
APIFlask is a lightweight Python web API framework based on Flask and marshmallow-code projects

APIFlask APIFlask is a lightweight Python web API framework based on Flask and marshmallow-code projects. It's easy to use, highly customizable, ORM/O

Grey Li 705 Jan 04, 2023
An easy-to-use high-performance asynchronous web framework.

An easy-to-use high-performance asynchronous web framework.

Aber 264 Dec 31, 2022