zoukankan      html  css  js  c++  java
  • 发布功能完成。

    def loginFirst(func):
        @wraps(func)
        def wrapper(*args,**kwargs):
            if session.get('user'):
                return func(*args,**kwargs)
            else:
                return redirect(url_for('login'))
        return wrapper
    
    @app.route('/fabu',methods=['GET','POST'])
    @loginFirst
    def fabu():
        if request.method =='GET':
            return render_template('fabu.html')
        else:
            title=request.form.get('title')
            detail=request.form.get('detail')
            author_id=User.query.filter(User.username==session.get('user')).first().id# 判断用户名是否存在
            question=Ques(title=title,detail=detail,author_id=author_id)
            db.session.add(question)
            db.session.commit()
            return redirect(url_for('lx'))
    {% extends 'lx3.html' %}
    {% block registertitle %}发布{% endblock %}
    {% block registerhead %}<script type="text/javascript" src="../static/js/js.js"></script>{% endblock %}
     <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet"  type="text/css" href="../static/css/webb.css" >
    <base href="www.gzcc.cn"target="_blank">
    <body>
    {% block body %}
        <div class="bigdiv">
        <h2>发布博客</h2>
            <form action="{{ url_for('fabu') }}" method="post">
        <label for="">标题</label>
    <textarea name="title" id="title" cols="50" rows="1"></textarea><br>
    <label for="">内容</label>
    <textarea name="detail" id="detail" cols="50" rows="10"></textarea><br>
        <div align="center"><button >发布</button></div>
                </form>
        </div>
    
    {% endblock %}
    </body>
    </html>

  • 相关阅读:
    维护
    zabbix监控线
    java——快排、冒泡、希尔、归并
    java——注解处理器
    spring boot——常用注解
    java——修改txt文件中某一行的内容
    spring boot——关于一个Mysql主键的问题
    mysql
    springboot
    自信点,不要怕
  • 原文地址:https://www.cnblogs.com/zheng01/p/7908786.html
Copyright © 2011-2022 走看看