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)
Pulumi-checkly - Checkly Pulumi Provider With Python

🚨 This project is still in very early stages and is not stable, use at your own

Checkly 16 Dec 15, 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
An easy-to-use high-performance asynchronous web framework.

中文 | English 一个易用的高性能异步 web 框架。 Index.py 文档 Index.py 实现了 ASGI3 接口,并使用 Radix Tree 进行路由查找。是最快的 Python web 框架之一。一切特性都服务于快速开发高性能的 Web 服务。 大量正确的类型注释 灵活且高效的

Index.py 264 Dec 31, 2022
News search API developed for the purposes of the ColdCase Project.

Saxion - Cold Case - News Search API Setup Local – Linux/MacOS Make sure you have python 3.9 and pip 21 installed. This project uses a MySQL database,

Dimitar Rangelov 3 Jul 01, 2021
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
Web-frameworks-benchmark

Web-frameworks-benchmark

Nickolay Samedov 4 May 13, 2021
Loan qualifier app - Loan Qualifier Application Built With Python

Loan Qualifier Application This program is designed to automate the discovery pr

Phil Hills 1 Jan 04, 2022
Daniel Vaz Gaspar 4k Jan 08, 2023
Async Python 3.6+ web server/framework | Build fast. Run fast.

Sanic | Build fast. Run fast. Build Docs Package Support Stats Sanic is a Python 3.6+ web server and web framework that's written to go fast. It allow

Sanic Community Organization 16.7k Jan 08, 2023
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
A comprehensive reference for all topics related to building and maintaining microservices

This pandect (πανδέκτης is Ancient Greek for encyclopedia) was created to help you find and understand almost anything related to Microservices that i

Ivan Bilan 64 Dec 09, 2022
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
Low code web framework for real world applications, in Python and Javascript

Full-stack web application framework that uses Python and MariaDB on the server side and a tightly integrated client side library.

Frappe 4.3k Dec 30, 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
A minimal, extensible, fast and productive API framework for Python 3.

molten A minimal, extensible, fast and productive API framework for Python 3. Changelog: https://moltenframework.com/changelog.html Community: https:/

Bogdan Popa 980 Nov 28, 2022
An abstract and extensible framework in python for building client SDKs and CLI tools for a RESTful API.

django-rest-client An abstract and extensible framework in python for building client SDKs and CLI tools for a RESTful API. Suitable for APIs made wit

Certego 4 Aug 25, 2022
Bromelia-hss implements an HSS by using the Python micro framework Bromélia.

Bromélia HSS bromelia-hss is the second official implementation of a Diameter-based protocol application by using the Python micro framework Bromélia.

henriquemr 7 Nov 02, 2022
Pretty tornado wrapper for making lightweight REST API services

CleanAPI Pretty tornado wrapper for making lightweight REST API services Installation: pip install cleanapi Example: Project folders structure: . ├──

Vladimir Kirievskiy 26 Sep 11, 2022
Bionic is Python Framework for crafting beautiful, fast user experiences for web and is free and open source

Bionic is fast. It's powered core python without any extra dependencies. Bionic offers stateful hot reload, allowing you to make changes to your code and see the results instantly without restarting

⚓ 0 Mar 05, 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