Skip to content

Commit 6247df3

Browse files
authored
Add files via upload
1 parent 385f5de commit 6247df3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
You can read tutorial https://www.roytuts.com/python-flask-http-basic-authentication/
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from flask import Flask
2+
from flask import jsonify
3+
from flask_httpauth import HTTPBasicAuth
4+
5+
app = Flask(__name__)
6+
auth = HTTPBasicAuth()
7+
8+
@app.route('/rest-auth')
9+
@auth.login_required
10+
def get_response():
11+
return jsonify('You are an authenticate person to see this message')
12+
13+
@auth.verify_password
14+
def authenticate(username, password):
15+
if username and password:
16+
if username == 'roy' and password == 'roy':
17+
return True
18+
else:
19+
return False
20+
return False
21+
22+
if __name__ == "__main__":
23+
app.run()

0 commit comments

Comments
 (0)