utility to execute a pythonscript from both commandline and webserver
Project description
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:
# 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cgli-0.0.4.tar.gz.
File metadata
- Download URL: cgli-0.0.4.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbf8ea0b25abc839b4b9e95cc38808501760a265e11d278cfd35e00a239c7ad8
|
|
| MD5 |
d2f6fdf97487f8e49008f51ffd0367a3
|
|
| BLAKE2b-256 |
022d0f3721f8f481fac8a08f6900343027cc9f311919b44ef0cb869312c28a1a
|
File details
Details for the file cgli-0.0.4-py3-none-any.whl.
File metadata
- Download URL: cgli-0.0.4-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8ebbd25102f46a316b257eb2af1a7a22ea67c514765bfd66934f221168d0860
|
|
| MD5 |
786f9c492ef06930b73bb1149ced0f4f
|
|
| BLAKE2b-256 |
5f81faaa553c14bab5356bd78cff3bf33e57490020712aa0346b6799e21a5c57
|