Welcome to Jolla
Jolla is a simple and fast API server written in Python 2.7.
Jolla is based on gevent's pywsgi
. because gevent
is based on a high performance lib , libev
, which is written in C language.
here is what gevent got(from gevent documentation):
- Fast event loop based on
libev
(epoll on Linux, kqueue on FreeBSD). - Lightweight execution units based on
greenlet
. - API that re-uses concepts from the
Python standard library
(for example there are gevent.event.Events and gevent.queue.Queues). - Cooperative sockets with SSL support
- DNS queries performed through threadpool or c-ares.
- Monkey patching utility to get 3rd party modules to become cooperative
and all above is included in Jolla
.
Jolla also got something special:
- Its own simple route rule.
- Easy and fast json response.
- Easy and short program structure for you to develop your project.
- Its easy error handler.
When I wrote Jolla
,what I want to do is a high performance API server for you to simply obey its short rule,and get your calculation result fast be sent to browser or mobile for your service.so I made Jolla
as simple as possible.
Hope you guys like it.
DOCUMENTATION
the Tutorial and documentation is 中文版 English Edition
INSTALL
pip install Jolla
or
git clone https://github.com/salamer/jolla
cd jolla
python setup.py install
QUICKSTART
Create a app.py
,and write dowm:
from jolla import server,SessionError,plugins,session,HTTP404Error
session = session()
def index(request):
return plugins.render('index.html')
def chinese(request):
res={}
res['ww']='海贼王'
return plugins.render_json(res)
def blog(request):
if request['method'] == 'GET':
return plugins.render_json({'name': session.get_value('name')})
else:
if request['method'] == 'POST':
session.add_value('name', request['name'])
return 'ok'
class app(server.WebApp):
urls = [
(r'/', index),
(r'/blog/<name>', blog),
(r'/chinese',chinese)
]
if __name__ == '__main__':
server = server.jolla_server(app)
server.run_server()
and then,run:
python app.py
Then open the http://127.0.0.1:8000 on your browser.
LICENSE
Copyright © 2016 by Aljun
Under Apache license : http://www.apache.org/licenses/