Пример #1
0
 def get(self, id=None):
     ctrl = TaskController()
     if id is None:
         tasklist = ctrl.list_all()
         js = json.dumps(tasklist)
         resp = Response(js,
                         status=200,
                         mimetype='application/json; charset=utf-8')
         return resp
     else:
         pass
Пример #2
0
# coding=UTF-8

import config
from flask import Flask, render_template, request, redirect
from controller import NodeController, RedisController, TaskController

app = Flask(__name__)
redis_controller = RedisController()
node_controller = NodeController(redis_controller.node_client)
task_controller = TaskController()


##################任务队列###########################
@app.route('/', methods=['GET'])
@app.route('/tasks/', methods=['GET'])
def task_lists():
    node_list = node_controller.node_list()
    executable_tasks = list()
    for n in node_list:
        executable_tasks.append(n['taskname'])
    task_list = task_controller.task_list()
    return render_template('tasks.html',
                           task_list=task_list,
                           executable_tasks=executable_tasks)


@app.route('/tasks/add/', methods=['POST'])
def add_task():
    taskname = request.form['name']
    tasknum = request.form['num']
    for _ in range(int(tasknum)):