Skip to content
Snippets Groups Projects
Commit d85d4f98 authored by Timo Asikainen's avatar Timo Asikainen
Browse files

copied the code running from xcese/test-app-parameters (Docker Hub); still to...

copied the code running from xcese/test-app-parameters (Docker Hub); still to resolve where is the source code
parent 215e6fcf
Branches master
No related tags found
No related merge requests found
#!flask/bin/python
import os
from flask import (Flask, make_response, redirect, render_template, request,url_for)
from flask import (Flask, make_response, redirect, render_template, request,
url_for)
import requests
app = Flask(__name__)
......@@ -16,28 +17,53 @@ parameters = {
url = parameters['name'] + "/" + parameters['endpoint']
# PKTN There seems to be a problem, as the code is not generic but contains the fixed group names. Where is the actual code?
@app.route('/simulient', methods=['GET'])
def html(content): # Also allows you to set your own <head></head> etc
return '<html><head><h3>This is the xCESE test page</h3></head><body>' + content + '</body></html>'
@app.route('/', methods=['GET'])
def returnHTML():
cookie = request.cookies
group = cookie.get("test-group")
if group == None:
group = 'None'
r = requests.get(url, headers = {"test-group": group})
c = r.json()
# print(r.content)
color_string = '#%02x%02x%02x' % (int(c['x']), int(c['y']), int(c['z']))
html_template = """
<p>How clear is the first row to read?</p>
<table>
<tr style="background-color:%s">
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<form>
<input type="submit" value="I like it!">
<input type="submit" value="Not so keen">
</form>
"""
return html(html_template % color_string)
@app.route('/simulient', methods=['GET'])
def returnJson():
cookie = request.cookies
print(cookie)
if cookie.get("test-group") == "group3":
r = requests.get(url, headers={"test-group": "group3"})
return r.json()
elif cookie.get("test-group") == "group4":
r = requests.get(url, headers={"test-group": "group4"})
return r.json()
elif cookie.get("test-group") == "group5":
r = requests.get(url, headers={"test-group": "group5"})
return r.json()
elif cookie.get("test-group") == "group6":
r = requests.get(url, headers={"test-group": "group6"})
return r.json()
else:
r = requests.get(url, headers={"test-group": "None"})
return r.json()
group = cookie.get("test-group")
if group == None:
group = 'None'
r = requests.get(url, headers = {"test-group": group})
# print(r.content)
return r.json()
if __name__ == '__main__':
app.run()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment