-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (22 loc) · 877 Bytes
/
app.py
File metadata and controls
29 lines (22 loc) · 877 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
from flask import Flask, request, jsonify
from flask_cors import CORS
from werkzeug.security import generate_password_hash, check_password_hash
app = Flask(__name__)
CORS(app)
# In a real application, this would be stored in a database
# This is just for demonstration
users = {
'admin': generate_password_hash('password123')
}
@app.route('/api/login', methods=['POST'])
def login():
data = request.get_json()
username = data.get('username')
password = data.get('password')
if username not in users:
return jsonify({'success': False, 'message': 'Invalid credentials'}), 401
if check_password_hash(users[username], password):
return jsonify({'success': True, 'message': 'Login successful'})
return jsonify({'success': False, 'message': 'Invalid credentials'}), 401
if __name__ == '__main__':
app.run(port=5000)