-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathget-secret.py
More file actions
25 lines (20 loc) · 815 Bytes
/
Copy pathget-secret.py
File metadata and controls
25 lines (20 loc) · 815 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
from flask import Flask, request
from flask.json import jsonify
import subprocess
app = Flask(__name__)
# In-memory dictionary to store secrets
secrets = {}
@app.route('/secret', methods=['GET'])
def get_secret():
secret_name = request.args.get('name')
if secret_name in secrets:
# If the secret is already stored, return it
return jsonify({secret_name: secrets[secret_name]})
else:
# If the secret is not stored, prompt the user for it
secret_value = subprocess.getoutput(f'osascript -e "display dialog \\"Enter the {secret_name}\\" default answer \\"\\" with hidden answer" -e "text returned of result"')
secrets[secret_name] = secret_value
return secret_value
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
# TODO: Linux support