A simple Flask-based HTTP pony server for extracting "Shannon-related" properties from images.
python ./setup.py install
The setup.py
script will install the shannon-server.py in /usr/local/bin
(or your operating system's equivalent) but you can also run it directly like this:
python ./script/shannon-server.py -c server.cfg
INFO:werkzeug: * Running on http://127.0.0.1:5000/
Or
setenv SHANNON_SERVER_CONFIG server.cfg
python ./scripts/shannon-server.py
INFO:werkzeug: * Running on http://127.0.0.1:5000/
You can also run shannon-server
from any WSGI-compliant container-server-thing-y. Consult the init.d folder for an example of how to use shannon-server
with gunicorn.
curl -X GET 'http://localhost:5000/ping'
{
"stat": "ok"
}
curl -X GET 'http://localhost:5000/entropy?file=test.png'
{
"entropy": 9.386720101697886,
}
curl -X POST -F 'file=@/tmp/test.jpg' 'http://localhost:5000/entropy'
{
"entropy": 9.386720101697886,
}
curl -X GET 'http://localhost:5000/focalpoint?file=test.png'
{
"entropy": 9.386720101697886,
"h": 480,
"w": 640,
"x": 100,
"y": 180
}
curl -X POST -F 'file=@/tmp/test.jpg' 'http://localhost:5000/focalpoint'
{
"entropy": 9.386720101697886,
"h": 480,
"w": 640,
"x": 100,
"y": 180
}
plumbing-shannon-server
uses utility functions exported by the
cooperhewitt.flask.http_pony
library which checks your Flask application's configuration for details about
how to handle things.
The following settings should be added to a standard ini style configutation file.
The Unix TCP port you want your Flask server to listen on.
If set then files sent using an HTTP GET
parameter will be limited to only
those that are are parented by this directory.
If it is not set then HTTP GET
requests will fail.
If set then files sent as an HTTP POST
request will be first written to this
directory before processing.
If not set then the operating system's temporary directory will be used.
A comma-separate list of valid file extensions for processing.