-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (30 loc) · 1001 Bytes
/
main.py
File metadata and controls
38 lines (30 loc) · 1001 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
37
38
from os import name
from flask import Flask, jsonify
import sqlite3
app = Flask(__name__)
@app.route('/')
def hello_world():
return "Hello, World"
@app.route('/login/<string:email>/<string:password>')
def login(email,password):
conn=sqlite3.connect("1.db")
cur=conn.cursor()
cur.execute("SELECT * FROM test WHERE email=? AND password=?",(email,password))
row=cur.fetchall()
conn.close()
print(row)
if row!=[]:
user_name=row[0][1]
return "user name found with name: "+user_name
else:
return "user not found "
@app.route('/signup_database/<string:name>/<string:email>/<string:password>')
def signup_database(name,email,password):
conn=sqlite3.connect("1.db")
cur=conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS test(id INTEGER PRIMARY KEY,name text,email text, password text)")
cur.execute("INSERT INTO test Values(Null,?,?,?)",(name,email,password))
conn.commit()
conn.close()
if __name__ == "__main__":
app.run(debug=True)