Exemplo n.º 1
0
def url_from_chrome():
    # url = json.loads(request.form.get('url'))
    url =request.args.get('url')
    title =request.args.get('title')
    content =request.args.get('content')
    type =request.args.get('type')
    print type
    id = request.args.get('id')
    share = Share(name=title, url=url, content=content, tag_id=int(type), author_id=int(id), is_pub=int(1))
    try:
        up_share(share)
        return "成功"
    except Exception, e:
        print e.message
        return "失败"
Exemplo n.º 2
0
def upurl():
    if session.get('name') is None:
        flash(u'你没有权限,请先登录再发布', 'alert-warning')
        return redirect(url_for('login'))
    share_form = ShareForm()

    if share_form.validate_on_submit():
        name = share_form.name.data.encode('utf-8')
        url = share_form.url.data.encode('utf-8')
        content = share_form.content.data.encode('utf-8')
        tag_id = share_form.tag.data
        public = share_form.public.data
        author_id = session.get('id')
        share = Share(name=name, url=url, content=content, tag_id=tag_id, author_id=int(author_id), is_pub=int(public))
        up_share(share)
        flash('up success!', 'alert-success')
        return redirect(url_for('upurl'))
    return render_template('upurl.html', form=share_form, name=session.get('name'))