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)
Library for building WebSocket servers and clients in Python

What is websockets? websockets is a library for building WebSocket servers and clients in Python with a focus on correctness and simplicity. Built on

Aymeric Augustin 4.3k Dec 31, 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
Sanic integration with Webargs

webargs-sanic Sanic integration with Webargs. Parsing and validating request arguments: headers, arguments, cookies, files, json, etc. IMPORTANT: From

Endurant Devs 13 Aug 31, 2022
Otter is framework for creating microservices in Flask like fassion using RPC communication via message queue.

Otter Framework for microservices. Overview Otter is framework for creating microservices in Flask like fassion using RPC communication via message qu

Volodymyr Biloshytskyi 4 Mar 23, 2022
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
Flask-Potion is a RESTful API framework for Flask and SQLAlchemy, Peewee or MongoEngine

Flask-Potion Description Flask-Potion is a powerful Flask extension for building RESTful JSON APIs. Potion features include validation, model resource

DTU Biosustain 491 Dec 08, 2022
TinyAPI - 🔹 A fast & easy and lightweight WSGI Framework for Python

TinyAPI - 🔹 A fast & easy and lightweight WSGI Framework for Python

xArty 3 Apr 08, 2022
A familiar HTTP Service Framework for Python.

Responder: a familiar HTTP Service Framework for Python Powered by Starlette. That async declaration is optional. View documentation. This gets you a

Taoufik 3.6k Dec 27, 2022
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
A library that makes consuming a RESTful API easier and more convenient

Slumber is a Python library that provides a convenient yet powerful object-oriented interface to ReSTful APIs. It acts as a wrapper around the excellent requests library and abstracts away the handli

Sam Giles 597 Dec 13, 2022
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
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
WebSocket and WAMP in Python for Twisted and asyncio

Autobahn|Python WebSocket & WAMP for Python on Twisted and asyncio. Quick Links: Source Code - Documentation - WebSocket Examples - WAMP Examples Comm

Crossbar.io 2.4k Jan 06, 2023
Klein - A micro-framework for developing production-ready web services with Python

Klein, a Web Micro-Framework Klein is a micro-framework for developing production-ready web services with Python. It is 'micro' in that it has an incr

Twisted Matrix Labs 814 Jan 08, 2023
Cses2humio - CrowdStrike Falcon Event Stream to Humio

CrowdStrike Falcon Event Stream to Humio This project intend to provide a simple

Trifork.Security 6 Aug 02, 2022
Serverless Python

Zappa - Serverless Python About Installation and Configuration Running the Initial Setup / Settings Basic Usage Initial Deployments Updates Rollback S

Rich Jones 11.9k Jan 01, 2023
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
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
Free & open source Rest API for YTDislike

RestAPI Free & open source Rest API for YTDislike, read docs.ytdislike.com for implementing. Todo Add websockets Installation Git clone git clone http

1 Nov 25, 2021
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