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)
Trame let you weave various components and technologies into a Web Application solely written in Python.

Trame Trame aims to be a framework for building interactive applications using a web front-end in plain Python. Such applications can be used locally

Kitware, Inc. 85 Dec 29, 2022
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
Python AsyncIO data API to manage billions of resources

Introduction Please read the detailed docs This is the working project of the next generation Guillotina server based on asyncio. Dependencies Python

Plone Foundation 183 Nov 15, 2022
Endpoints is a lightweight REST api framework written in python and used in multiple production systems that handle millions of requests daily.

Endpoints Quickest API builder in the West! Endpoints is a lightweight REST api framework written in python and used in multiple production systems th

Jay Marcyes 30 Mar 05, 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
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
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
Lemon is an async and lightweight API framework for python

Lemon is an async and lightweight API framework for python . Inspired by Koa and Sanic .

Joway 29 Nov 20, 2022
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
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
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
Official mirror of https://gitlab.com/pgjones/quart

Quart Quart is an async Python web microframework. Using Quart you can, render and serve HTML templates, write (RESTful) JSON APIs, serve WebSockets,

Phil Jones 2 Oct 05, 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 Flask API REST to access words' definition

A Flask API to access words' definitions

Pablo Emídio S.S 9 Jul 22, 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
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
Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.

Japronto! There is no new project development happening at the moment, but it's not abandoned either. Pull requests and new maintainers are welcome. I

Paweł Piotr Przeradowski 8.6k Dec 29, 2022
Django Ninja - Fast Django REST Framework

Django Ninja is a web framework for building APIs with Django and Python 3.6+ type hints.

Vitaliy Kucheryaviy 3.8k Jan 02, 2023
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
Goblet is an easy-to-use framework that enables developers to quickly spin up fully featured REST APIs with python on GCP

GOBLET Goblet is a framework for writing serverless rest apis in python in google cloud. It allows you to quickly create and deploy python apis backed

Austen 78 Dec 27, 2022