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)
Web3.py plugin for using Flashbots' bundle APIs

This library works by injecting a new module in the Web3.py instance, which allows submitting "bundles" of transactions directly to miners. This is done by also creating a middleware which captures c

Georgios Konstantopoulos 294 Jan 04, 2023
Developer centric, performant and extensible Python ASGI framework

Introduction xpresso is an ASGI web framework built on top of Starlette, Pydantic and di, with heavy inspiration from FastAPI. Some of the standout fe

Adrian Garcia Badaracco 119 Dec 27, 2022
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
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
🦍 The Cloud-Native API Gateway

Kong or Kong API Gateway is a cloud-native, platform-agnostic, scalable API Gateway distinguished for its high performance and extensibility via plugi

Kong 33.8k Jan 09, 2023
Web-frameworks-benchmark

Web-frameworks-benchmark

Nickolay Samedov 4 May 13, 2021
A boilerplate Flask API for a Fullstack Project with some additional packages and configuration prebuilt. ⚙

Flask Boilerplate to quickly get started with production grade flask application with some additional packages and configuration prebuilt.

Yasser Tahiri 32 Dec 24, 2022
Chisel is a light-weight Python WSGI application framework built for creating well-documented, schema-validated JSON web APIs

chisel Chisel is a light-weight Python WSGI application framework built for creating well-documented, schema-validated JSON web APIs. Here are its fea

Craig Hobbs 2 Dec 02, 2021
A simple Tornado based framework designed to accelerate web service development

Toto Toto is a small framework intended to accelerate web service development. It is built on top of Tornado and can currently use MySQL, MongoDB, Pos

Jeremy Olmsted-Thompson 61 Apr 06, 2022
A high-level framework for building GitHub applications in Python.

A high-level framework for building GitHub applications in Python. Core Features Async Proper ratelimit handling Handles interactions for you (

Vish M 3 Apr 12, 2022
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
Fully featured framework for fast, easy and documented API development with Flask

Flask RestPlus IMPORTANT NOTICE: This project has been forked to Flask-RESTX and will be maintained by by the python-restx organization. Flask-RESTPlu

Axel H. 2.7k Jan 04, 2023
Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.

Tornado Web Server Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. By using non-blocking ne

20.9k 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
A tool for quickly creating REST/HATEOAS/Hypermedia APIs in python

ripozo Ripozo is a tool for building RESTful/HATEOAS/Hypermedia apis. It provides strong, simple, and fully qualified linking between resources, the a

Vertical Knowledge 198 Jan 07, 2023
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
A micro web-framework using asyncio coroutines and chained middleware.

Growler master ' dev Growler is a web framework built atop asyncio, the asynchronous library described in PEP 3156 and added to the standard library i

687 Nov 27, 2022
Try to create a python mircoservice framework.

Micro current_status: prototype. ... Python microservice framework. More in Document. You should clone this project and run inv docs. Install Not now.

修昊 1 Dec 07, 2021
Asita is a web application framework for python based on express-js framework.

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 frameworks because it is based on express-js framework.

Mattéo 4 Nov 16, 2021
You can use the mvc pattern in your flask application using this extension.

You can use the mvc pattern in your flask application using this extension. Installation Run the follow command to install mvc_flask: $ pip install mv

Marcus Pereira 37 Dec 17, 2022