You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.9 KiB
75 lines
1.9 KiB
4 years ago
|
#!/usr/bin/python3
|
||
|
|
||
|
|
||
|
def set_original_response():
|
||
|
test_return_data = """<html>
|
||
4 years ago
|
<head><title>head title</title></head>
|
||
|
<body>
|
||
4 years ago
|
Some initial text</br>
|
||
|
<p>Which is across multiple lines</p>
|
||
|
</br>
|
||
|
So let's see what happens. </br>
|
||
|
</body>
|
||
|
</html>
|
||
|
"""
|
||
|
|
||
3 years ago
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
||
4 years ago
|
f.write(test_return_data)
|
||
|
return None
|
||
|
|
||
|
def set_modified_response():
|
||
|
test_return_data = """<html>
|
||
4 years ago
|
<head><title>modified head title</title></head>
|
||
|
<body>
|
||
4 years ago
|
Some initial text</br>
|
||
|
<p>which has this one new line</p>
|
||
|
</br>
|
||
|
So let's see what happens. </br>
|
||
|
</body>
|
||
|
</html>
|
||
|
"""
|
||
|
|
||
3 years ago
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
||
4 years ago
|
f.write(test_return_data)
|
||
|
|
||
|
return None
|
||
|
|
||
|
|
||
|
def live_server_setup(live_server):
|
||
|
|
||
3 years ago
|
|
||
4 years ago
|
@live_server.app.route('/test-endpoint')
|
||
|
def test_endpoint():
|
||
|
# Tried using a global var here but didn't seem to work, so reading from a file instead.
|
||
3 years ago
|
with open("test-datastore/endpoint-content.txt", "r") as f:
|
||
4 years ago
|
return f.read()
|
||
|
|
||
3 years ago
|
# Just return the headers in the request
|
||
|
@live_server.app.route('/test-headers')
|
||
|
def test_headers():
|
||
|
|
||
|
from flask import request
|
||
|
output= []
|
||
|
|
||
|
for header in request.headers:
|
||
|
output.append("{}:{}".format(str(header[0]),str(header[1]) ))
|
||
|
|
||
|
return "\n".join(output)
|
||
|
|
||
|
|
||
4 years ago
|
# Where we POST to as a notification
|
||
4 years ago
|
@live_server.app.route('/test_notification_endpoint', methods=['POST'])
|
||
|
def test_notification_endpoint():
|
||
4 years ago
|
from flask import request
|
||
|
|
||
4 years ago
|
with open("test-datastore/notification.txt", "wb") as f:
|
||
4 years ago
|
# Debug method, dump all POST to file also, used to prove #65
|
||
|
data = request.stream.read()
|
||
|
if data != None:
|
||
4 years ago
|
f.write(data)
|
||
4 years ago
|
|
||
4 years ago
|
print("\n>> Test notification endpoint was hit.\n")
|
||
|
return "Text was set"
|
||
|
|
||
4 years ago
|
live_server.start()
|