403禁止我的每一页的底部

时间:2013-06-19 17:23:20

标签: python python-2.7 flask flask-wtforms flask-login

我正在制作一个博客页面 我在每个页面底部都收到一条消息。

消息说:
“” * * 403 Fobidden

  • 代码:AccessDenied
  • 消息:访问被拒绝
  • RequestID:12D5257EEFBC8528
  • 主机ID:**
    ** “”

请指导我

我的ROUTE PAGE包含的连接如下所示::

from flask import *
from functools import wraps
import sqlite3

DATABASE = 'message.db'

app = Flask(__name__)
app.config.from_object(__name__)

app.secret_key = "my key"

def connect_db():
    return sqlite3.connect(app.config['DATABASE'])

@app.route('/')
def home():
    return render_template('home.html')

@app.route('/message')
def message():
    g.db = connect_db()
    cur = g.db.execute('select msg_msg from msg')
    message = [dict(msg_msg=row[0]) for row in cur.fetchall()]
    g.db.close()
    return render_template('message.html', message=message)


def login_required(test):
    @wraps(test)
    def wrap(*args, **kwargs):
        if 'logged_in' in session:
            return test(*args, **kwargs)
        else:
            flash('You need to Login First.')
            return redirect(url_for('log'))
    return wrap

@app.route('/logout')
def logout():
    session.pop('logged_in', None)
    flash('You were logged out')
    return redirect(url_for('log'))


@app.route('/hello')
@login_required
def hello():
    g.db = connect_db()
    cur = g.db.execute('select msg_msg from msg')
    message = [dict(msg_msg=row[0]) for row in cur.fetchall()]




@app.route('/log', methods=['GET', 'POST'])
def log():
    error = None
    if request.method == 'POST':
        if request.form['username'] != 'admin' or request.form['password'] != 'admin':
            error = 'Invalid Entry, Please Try Again.'
        else:
            session['logged_in'] = True
            return redirect(url_for('hello'))
        return render_template('log.html' , error=error)


@app.route('/add', methods=['POST'])
def add_entry():
    g.db = connect_db()
    cur = g.db.execute('insert into msg (msg_msg) values (?)', [request.form['input_msg']])
    g.db.commit()
    flash('New Entry was SUCCESSFULLY POSTED.')
    return redirect(url_for('message'))


if __name__ == '__main__':
    app.run(debug=True)

0 个答案:

没有答案