Exemplo n.º 1
0
  def show(self, peer_uri):
    import urllib
    
    self.path=["Peers", peer_uri]

    peer = self.__find_peer(peer_uri)
    if not peer:
      return T.h1("Not Found")
    
    messages = list()

    for m_id in peer.queue:
      message = peer.queue[m_id]

      if message.completed:
        messages.append(
          T.div()[
            T.h4()[message.id],
            T.pre(style="background-color: #dedede; border: 1px dotted #999; width: 50%;")[
              message.message
            ]
          ]
        )
      else:
        messages.append(
          T.div()[
            T.h4()[message.id],
            T.pre(style="background-color: #dedede; border: 1px dotted #999; width: 50%;")[
              "not complete"
            ]
          ]
        )
    
    return [
      T.h1()[peer_uri],
      T.p()["This is a paragraph"],
      T.p()["messages received:"],
      T.div()[messages]
    ]
Exemplo n.º 2
0
 def broadcast(self):
   self.path = ["Peers", "Broadcast"]
   
   return [
     T.h1()["Broadcast to All Peers"],
     T.form(action=url_for('peers_broadcast'), method="POST")[
       T.text_area(name="broadcast_message", cols="60", rows="20"),
       T.br(),
       T.file_input('broadcast_file'),
       T.br(),
       T.input(name="submit_broadcast_message", type="submit", value="Send Broadcast")
     ]
   ]