Skip to content

Instantly share code, notes, and snippets.

@soodoku
Last active July 16, 2023 17:36
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Remote Logging of Errors With User Approval
from flask import Flask, request
import uuid
app = Flask(__name__)
@app.route('/error_endpoint', methods=['POST'])
def receive_error_message():
error_message = request.form.get('error_message')
if error_message:
unique_filename = str(uuid.uuid4()) + ".txt"
with open(unique_filename, 'w') as file:
file.write(error_message)
return "Error message received and stored successfully!"
else:
return "Error: No error message received."
if __name__ == '__main__':
app.run(port=5001)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment