Exemplo n.º 1
0
def autoRobotAnswer(id, question_model):
    pid = os.fork()
    if pid != 0:
        return
    url = "http://47.104.98.154:8080/anonymous/wordManage/wenda"
    headers = {'content-type': "application/json"}
    query_string = {"question": question_model.title, "robotid": "1791"}

    if (len(question_model.answers) < 1):

        response = requests.post(url, data=json.dumps(query_string), headers=headers)
        jstr = response.text
        # error : {"result":false,"message":"服务器处理异常!","data":null}
        print jstr
        if (jstr['message'] == 'success'):
            print jstr['message']
            question_id = id
            print question_id

            content = jstr['data']['answers']
            print content
            answer_model = AnswerModel(content=content)
            answer_model.author = 'robot'
            answer_model.question = question_model
            db.session.add(answer_model)
            db.session.commit()
Exemplo n.º 2
0
def comment():
    question_id = flask.request.form.get('question_id')
    content = flask.request.form.get('content')
    answer_model = AnswerModel(content=content)
    answer_model.author = flask.g.user
    answer_model.question = QuestionModel.query.get(question_id)
    db.session.add(answer_model)
    db.session.commit()
    return flask.redirect(flask.url_for('detail',id=question_id))
Exemplo n.º 3
0
def comment():
    question_id = flask.request.form.get('question_id')
    content = flask.request.form.get('content')
    answer_model = AnswerModel(content=content)
    answer_model.author = UserModel.query.filter_by(username='******').first()
    answer_model.question = QuestionModel.query.get(question_id)
    db.session.add(answer_model)
    db.session.commit()
    return flask.redirect(flask.url_for('detail',id=question_id))
Exemplo n.º 4
0
Arquivo: yan.py Projeto: yanfujin/yan
def comment():
    upload_id = request.form.get('upload_id')
    content = request.form.get('contentt')

    answermodel = AnswerModel(content=content)
    id = session.get('id')
    user = UserModel.query.filter(UserModel.id == id).first()
    answermodel.author = user

    upload = UploadModel.query.filter(UploadModel.id == upload_id).first()
    answermodel.upload = upload
    db.session.add(answermodel)
    db.session.commit()
    return redirect(url_for('detial', id=upload_id))