tested on ubuntu docker for pip3 install web3py with simple app (worked)
*steps*
apt install -y git python3-pip cython3 
cd
git clone https://github.com/web2py/web3py
cd web3py
python3 setup.py install
pip3 install web3py
cd 
mkdir -p ~/apps/test/databases
cat << EOF > ~/apps/test/__init__.py
import os
from web3py import *
db = DAL('sqlite://test', folder=os.path.join(os.path.dirname(__file__), 
'databases'))
db.define_table('table0', Field('field0') )
if db(db.table0).count() == 0:
    db.table0.insert(field0 = 'field 0')
    db.table0.insert(field0 = 'field 1')
db.commit()
@action('rows_as_json/<table_name>', method = 'GET')
@action.uses(db)
def rows_as_json(table_name):
    query = (db[table_name]['id'] > 0)
    rows = db(query).select().as_json()
    response.content_type = 'application/json; charset=utf-8'
    return rows
    #return dict(rows = rows)
EOF
touch ./apps/__init__.py
cd ~/apps
cd
python3 -c "from pydal.validators import CRYPT; 
open('password.txt','w').write(str(CRYPT()('a' )[0] ) )"
/usr/local/bin/web3py-start -p ./password.txt -a 0.0.0.0:8000 ./apps &

*test on terminal*
$ curl -X GET -i http://localhost:8000/test/rows_as_json/table0
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 64
Server: TornadoServer/6.0.2

[{"id": 1, "field0": "field 0"}, {"id": 2, "field0": "field 1"}]

*test on browser : http://localhost:8000/test/rows_as_json/table0*
[{"id": 1, "field0": "field 0"}, {"id": 2, "field0": "field 1"}]

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/c1cfab67-43c0-4a27-8973-503fd24a2c89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to