forked from EN10/FlaskLogin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.py
30 lines (25 loc) · 766 Bytes
/
debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask
import sqlite3
app = Flask(__name__)
@app.route('/tables')
def tables():
con = sqlite3.connect('login.db')
cur = con.cursor()
cur.execute("SELECT * FROM sqlite_master")
rows = cur.fetchall()
return str(rows)
@app.route('/insert', methods=['POST'])
def insert():
con = sqlite3.connect('login.db')
cur = con.cursor()
try:
cur.execute("INSERT INTO Users (Username, Password) VALUES (?,?)",
(request.form['un'],request.form['pw']))
except Exception as e:
return str(e)
con.commit()
return request.form['un'] + ' added'
# print to pythonanywhere error log
# might be faster to run function() and click Run rather the Reload
import sys
print("fatal error", file=sys.stderr)