Metadata-Version: 2.1
Name: radiant
Version: 3.3.7
Summary: Brython Framework
Home-page: UNKNOWN
Author: Yeison Cardona
Author-email: yencardonaal@unal.edu.co
Maintainer: Yeison Cardona
Maintainer-email: yencardonaal@unal.edu.co
License: BSD-2-Clause
Download-URL: https://github.com/UN-GCPDS/brython-radiant
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE

# Brython-Radiant

A Brython Framework for Web Apps development.

![GitHub top language](https://img.shields.io/github/languages/top/un-gcpds/brython-radiant?)
![PyPI - License](https://img.shields.io/pypi/l/radiant?)
![PyPI](https://img.shields.io/pypi/v/radiant?)
![PyPI - Status](https://img.shields.io/pypi/status/radiant?)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/radiant?)
![GitHub last commit](https://img.shields.io/github/last-commit/un-gcpds/brython-radiant?)
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/UN-GCPDS/brython-radiant?)
[![Documentation Status](https://readthedocs.org/projects/radiant/badge/?version=latest)](https://radiant-framework.readthedocs.io/en/latest/?badge=latest)

Radiant is a [Brython](https://brython.info/) framework for the quick development of web apps with pure Python/Brython syntax so there is no need to care about (if you don’t want) HTML, CSS, or Javascript. Run over [Tornado](https://www.tornadoweb.org/) servers and include support to [Websockets](notebooks/02-additional_features.ipynb#WebSockets), [Python Scripts](notebooks/02-additional_features.ipynb#Python-scripting) and [MDC](notebooks/02-additional_features.ipynb#Custom-themes).

## Instalation


```python
pip install radiant
```

## Usage

### Bare minimum


```python
# Radiant modules
from radiant.server import RadiantAPI

# Brython modules
from browser import document, html  # This modules are faked after `radiant` inport

# Main class inheriting RadiantAPI
class BareMinimum(RadiantAPI):

    # Constructor 
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
    
        #-----------------------------------------------------------
        # Brython code (finally)
        document.select_one('body') <= html.H1('Hello World')
        #
        # ...all your brython code
        #-----------------------------------------------------------

# Run server
if __name__ == '__main__':
    BareMinimum()
```

### Extra options


```python
# Radiant modules
from radiant.server import RadiantAPI, RadiantServer  # import RadiantServer for advanced options

from browser import document, html

# Main class inheriting RadiantAPI
class BareMinimum(RadiantAPI):

    def __init__(self, *args, **kwargs):
        """"""
        super().__init__(*args, **kwargs)

        #-----------------------------------------------------------
        # Brython code
        document.select_one('body') <= html.H1('Hello World')
        #
        # ...all your brython code
        #-----------------------------------------------------------
        
if __name__ == '__main__':
    # Advance options
    RadiantServer('BareMinimum',
                  host='localhost',
                  port=5000,
                  brython_version='3.9.1',
                  debug_level=0,
                  )
```

## How to works

This is basically a set of scripts that allows the same file run from _Python_ and _Brython_, when is running under _Python_ a [Tornado](https://www.tornadoweb.org/) server is created and configure the local path for serving static files, and a custom HTML template is configured in runtime to import the same script, this time under _Brython_, is very simple.


