Exemplo n.º 1
0
def response(asock, data, address):
    """定义反应行为,如果接收到信息为KEYWORD,发回日记历史,否则则将信息记入日记"""
    if data == 'q':
        back_message = alan_diary.get_text()
        sent = asock.sendto(back_message, address)
        print '发回{}字节信息给{}'.format(sent, address)
    else:
        alan_diary.append_text(data)
Exemplo n.º 2
0
def write():
    mydiary = get_text()  # 获取日记数据
    return template("write", diary=mydiary)
Exemplo n.º 3
0
def do_write():
    input_md = request.forms.get("input_md")  # 抓取form里提交的数据
    append_text(input_md)  # 将数据写入log文件
    mydiary = get_text()
    return template("write", diary=mydiary)