-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
31 lines (27 loc) · 956 Bytes
/
main.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
from flask import Flask
from flaskext.mysql import MySQL
from flask import Flask,request
import os
mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = os.getenv("db_user")
app.config['MYSQL_DATABASE_PASSWORD'] = os.getenv("db_password")
app.config['MYSQL_DATABASE_DB'] = os.getenv("db_name")
app.config['MYSQL_DATABASE_HOST'] = os.getenv("db_host")
mysql.init_app(app)
@app.route("/")
def hello():
return "Welcome to Python Flask App!"
@app.route("/Authenticate")
def Authenticate():
username = request.args.get('UserName')
password = request.args.get('Password')
cursor = mysql.connect().cursor()
cursor.execute("SELECT * from User where Username='" + username + "' and Password='" + password + "'")
data = cursor.fetchone()
if data is None:
return "Username or Password is wrong"
else:
return "Logged in successfully"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080)