simple db connection
This commit is contained in:
parent
ab205f316b
commit
978107b551
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,3 +1,4 @@
|
||||
{
|
||||
"python.pythonPath": "${workspaceFolder}/venv/bin/python"
|
||||
"python.pythonPath": "${workspaceFolder}/venv/bin/python",
|
||||
"python.linting.pylintEnabled": false
|
||||
}
|
28
App.py
28
App.py
@ -8,9 +8,11 @@ DATABASE = 'inquire.db'
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
|
||||
'''
|
||||
with app.app_context():
|
||||
db = g._database = sqlite3.connect(DATABASE)
|
||||
db_conn = db.cursor()
|
||||
'''
|
||||
@app.route('/')
|
||||
def home():
|
||||
if not session.get('logged_in'):
|
||||
@ -23,13 +25,15 @@ def home():
|
||||
|
||||
@app.route('/student',methods=['GET', 'POST'])
|
||||
def student():
|
||||
return render_template('student.html')
|
||||
|
||||
@app.route('/ask', methods=['POST'])
|
||||
def do_add():
|
||||
if request.method == 'POST':
|
||||
question = request.get_data().decode("utf-8")
|
||||
question = question.split('=')
|
||||
print(question[1])
|
||||
return '200'
|
||||
else:
|
||||
return render_template('student.html')
|
||||
|
||||
@app.route('/lecturer')
|
||||
def lecturer():
|
||||
@ -54,13 +58,13 @@ def logout():
|
||||
|
||||
@app.route('/upvote', methods=['POST'])
|
||||
def upvote():
|
||||
if request.method == 'POST':
|
||||
print("upvoted")
|
||||
with app.app_context():
|
||||
db = g._database = sqlite3.connect(DATABASE)
|
||||
db.execute("select * from user;")
|
||||
print(db.fetchone())
|
||||
return '200'
|
||||
print("upvoted")
|
||||
db = sqlite3.connect(DATABASE)
|
||||
#db.row_factory = sql.Row
|
||||
db_conn = db.cursor()
|
||||
db_conn.execute("select * from user;")
|
||||
print(db_conn.fetchone())
|
||||
return '200'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user