Giter Site home page Giter Site logo

jolla's Introduction

pic

Jolla

jolla is a pure API server framework,and it is based on the gevent.

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.

INSTALL

sudo pip install jolla

DOCUMENTATION

wanna know more,please click read more

the Tutorial and documentation is 中文版 English edition

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):
    try:
        if request['data']['ww']=='海贼王':
            return 'great anime'
    except:
        pass
    return 'yeah!chinese'


def data(request):
    data = {'data': request['id']}
    return plugins.render_json(data)


def add(request):
    session.add_value('qq', 'ww')

    return 'yes'


def get(request):
    try:
        data = session.get_value('qq')
    except SessionError:
        raise HTTP404Error
    return data


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['data']['name'])
            return 'ok'

def re_target(request):
    return plugins.redirect("/data")


class app(server.WebApp):
    urls = [
        (r'/', index),
        (r'/data/<id>', data),
        (r'/data', data),
        (r'/add', add),
        (r'/get', get),
        (r'/blog', blog),
        (r'/chinese',chinese),
        (r'/redirect',re_target)
    ]

if __name__ == '__main__':
    server = server.jolla_server(app)
    server.run_server()

and then,run:

python app.py

and open the http://127.0.0.1:8000 on your browser

you will see the magic happen!

LICENSE

Copyright © 2016 by Aljun

Under Apache license : http://www.apache.org/licenses/

jolla's People

Contributors

salamer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.