-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
36 lines (31 loc) · 937 Bytes
/
Copy pathapp.py
File metadata and controls
36 lines (31 loc) · 937 Bytes
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
from flask import Flask, render_template, request
import sqlite3
app = Flask(__name__)
@app.route('/')
def login():
return render_template('login.html')
@app.route('/signup')
def signup():
return render_template('signup.html')
@app.route('/select', methods=['post'])
def select():
con = sqlite3.connect('login.db')
cur = con.cursor()
cur.execute("SELECT * FROM users WHERE username=? AND password=?",
(request.form['un'],request.form['pw']))
match = len(cur.fetchall())
con.close()
if match == 0:
return "wrong username and password"
else:
return "welcome " + request.form['un']
@app.route('/insert', methods=['post'])
def insert():
con = sqlite3.connect("login.db")
cur = con.cursor()
cur.execute(""" INSERT INTO users (username, password)
VALUES (?, ?) """,
(request.form['un'], request.form['pw']))
con.commit()
con.close()
return 'signup successful'