cgli-0.0.4
توضیحات
utility to execute a pythonscript from both commandline and webserver
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | cgli-0.0.4 |
| نام | cgli |
| نسخه کتابخانه | 0.0.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Toni Cornelissen |
| ایمیل نویسنده | cgli@technetium.be |
| آدرس صفحه اصلی | https://github.com/technetium/cgli/ |
| آدرس اینترنتی | https://pypi.org/project/cgli/ |
| مجوز | - |
# 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
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.5 | Python |
نحوه نصب
نصب پکیج whl cgli-0.0.4:
pip install cgli-0.0.4.whl
نصب پکیج tar.gz cgli-0.0.4:
pip install cgli-0.0.4.tar.gz