-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
43 lines (32 loc) · 1.08 KB
/
app.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
32
33
34
35
36
37
38
39
40
from flask import Flask, render_template
from flask_httpauth import HTTPBasicAuth
from werkzeug.security import generate_password_hash, check_password_hash
import connexion
import requests
import myapi
#Create the application instance!
app = connexion.App(__name__, specification_dir='./')
auth = HTTPBasicAuth()
users = {
"john": generate_password_hash("hello"),
"susan": generate_password_hash("bye")
}
@auth.verify_password
def verify_password(username, password):
if username in users and \
check_password_hash(users.get(username), password):
return username
#Read the swagger.yml file to configure the endpoints
app.add_api('swagger.yml')
#Create a URL route in our application for "/"
@app.route('/', methods=["GET","POST"])
@auth.login_required
def home():
#return "Hello, {}!".format(auth.current_user())
if(auth.current_user()):
#uname = auth.current_user()
return render_template('home.html', username=auth.username())
else:
print("ERROR")
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True)