2020-09-16 21:41:55 +00:00
|
|
|
from flask import Flask, abort, request
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
import auth_functions
|
|
|
|
import secrets
|
|
|
|
|
|
|
|
HTTP_UNAUTHORIZED = 401
|
|
|
|
|
|
|
|
def check_auth():
|
|
|
|
auth_header = request.headers.get('Authorization', '')
|
|
|
|
if auth_header != 'Token ' + secrets.AUTH_TOKEN:
|
|
|
|
abort(HTTP_UNAUTHORIZED)
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
return '<i>SEE YOU SPACE SAMURAI...</i>'
|
|
|
|
|
|
|
|
@app.route('/set-password', methods=['POST'])
|
|
|
|
def set_password():
|
|
|
|
check_auth()
|
|
|
|
|
|
|
|
username = request.form['username']
|
|
|
|
password = request.form['password']
|
|
|
|
|
2020-09-16 22:14:27 +00:00
|
|
|
auth_functions.set_wiki_password(username, password)
|
2020-09-16 21:41:55 +00:00
|
|
|
return ''
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
app.run(debug=True, host='0.0.0.0')
|