Metadata-Version: 2.1
Name: cgli
Version: 0.0.4
Summary: utility to execute a pythonscript from both commandline and webserver
Home-page: https://github.com/technetium/cgli/
Author: Toni Cornelissen
Author-email: cgli@technetium.be
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.5
Description-Content-Type: text/markdown

# cgli

A utility to use a python program from both command line (cli) as website (cgi)

## Installation

Use pip to install *cgli*

```
	pip install cgli
```

## Usage

Example script:

```python
# import the application_make 
# and application_execute functions
# from the cgli module
from cgli import application_maker, application_execute


# define the arguments
arguments = {
    'string'  : { 'short': 's', 'help': 'a string' },
    'number'  : { 'short': 'n', 'help': 'a number', 'type': int },
    'another' : { 'short': 'a', 'help': 'another number', 'default': 42, 'type': int },
}

# define a function with the arguments defined above
def some_function(string, number, another):
    # do something
    sum = number + another
    
    # return something
    return {
        'string': 'The string is %s' % string,
        'number': 'The number is %d' % number,
        'sum': sum,
    }
    

# make the application and execute it
application_execute(application_maker(some_function, arguments))
```

### Command line

Show arguments:
```
$ ./example.py -h
```
Use arguments (long and short attribute names can be combined):
```
$ ./example.py -s"Hello World" --number 3
```

### Webserver

Show arguments:
```
http://example.com/example.py?h
```
Use arguments (only long attribute names can be used)
```
http://example.com/example.py?string=Hello+World&number=3
```


