Giter VIP home page Giter VIP logo

allegro's Introduction

Allegro

Join the chat at https://gitter.im/Alecyrus/Lobby Build Status PyPI version PyPI

Allegro is a python backend integration framework, which provides a simple way to make the task of building any kind of RESTFul system easy and efficient. The RESTFul service is based on sanic, and Celery provides tasks scheduler service.

With the framework, the API can be defined through a config file, and we just focus on the processing logic. What's more, it' very efficient and easy for frond-end to build a mock server.

Installation

pip3 install allegro

It only supports Python3.5 or higher.

Get Started

start.py

from allegro import Allegro

app = Allegro("test_project")
app.initialize("test.ini")
app.start()

stop.py

from allegro import Allegro

app = Allegro("test_project")
app.initialize("test.ini")
app.stop()

task1.py

from celery import Celery

app = Celery('tasks', backend='redis://localhost:6379/0', broker = 'redis://localhost:6379/0')


@app.task
def get(message):
    print(message)
    return {"app":"Get Got"}

@app.task
def post(message):
    print(message)
    return {"app":"Post Got"}

settings.ini

[basic]
;The ip address of the host you runs the RESTFul API service
bind_host = 0.0.0.0
;The port
bind_port = 8000
;The number of the RESTFul API service process
api_worker = 3
;The directory where the consumer modules you defined can be found 
root_path = /home/luze/Code/Allegro/examples
;The file that contains the pids of all the process
pid_path = /tmp/my_project_pid_file
;Timeout
timeout = 60

[service]
;The services your projects provided. If you want to define more than
;one service, separate each service's name by a comma. And then you must 
;define every service's specific information with a section named after
;the service'name.
keys = Test1Service


[Test1Service]
;The uri of the service. And the api can be accessed by the url;
;(http://bind_host:bind_port/uri)
uri = /test1
;The HTTP method the service's API provided.
method = get,post
;The module where the handler class is located
module = task1
;The number of the service workers. If the value of eventlet_enabled is True, the item will be of no effect
workers = 3
processes_pool = 10
;use eventlet  
eventlet_enabled = True
eventlet_pool = 1000

file_upload_enabled = False

Run the command:

# python3 start.py

Call the API(example: http://localhost:8000/test1 (POST))

Respose:

{"app":"Get Got"}

Run python3 stop.py to terminate the program.

License

Allegro is open source and released under the MIT Licence.

allegro's People

Contributors

alecyrus avatar gitter-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.