Exemplo n.º 1
0
def post(request, message):
  view = JSONView()
  result = chat.post(message)
  view.data = {
    'result': result,
  }
  return view.render()
Exemplo n.º 2
0
def refresh(request, last_time):
  view = JSONView()
  result, chats = chat.refresh(last_time)
  view.data = {
    'result': result,
    'chats': chats,
  }
  return view.render()
Exemplo n.º 3
0
def post(request):
  view = JSONView()
  view.data = {
    'result': False,
  }
  if request.method == 'POST':
    result = news.post(request.POST.title, request.POST.link, request.POST.content)
    if result == False:
      view.data['error'] = 'Database error'
  else:
    view.data['error'] = 'This action requires POST method'
  return view.render()
Exemplo n.º 4
0
def refresh(request, last_time):
  view = JSONView()
  view.data = {
    'result': result,
  }
  if request.method == 'POST':
    result, news = news.refresh(last_time)
    if result == True:
      view.data['news'] = news
    else:
      view.data['error'] = 'Database error'
  else:
    view.data['error'] = 'This action requires POST method'
  return view.render()