forked from EN10/FlaskLogin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup.py
44 lines (40 loc) · 988 Bytes
/
signup.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from flask import Flask, render_template, request
import sqlite3
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/signup', methods=['POST'])
def signup():
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute("""
INSERT INTO login (username, password)
VALUES (?, ?)
""",
(request.form['username'], request.form['password'])
)
con.commit()
return 'signup successful'
@app.route('/insert')
def insert():
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute("""
INSERT INTO login (username, password)
VALUES ("bob", "123")
""")
con.commit()
return 'bob added'
@app.route('/table')
def table():
con = sqlite3.connect("database.db")
cur = con.cursor()
cur.execute("""
CREATE TABLE login
(
username VARCHAR(20) NOT NULL PRIMARY KEY,
password VARCHAR(20) NOT NULL
)
""")
return 'table created!'