diff --git a/apicall.py b/apicall.py
new file mode 100644
index 0000000..7908d3e
--- /dev/null
+++ b/apicall.py
@@ -0,0 +1,68 @@
+import requests
+from datetime import datetime
+
+
+def extract_time(json):
+
+ print "extract_time"
+ try:
+ return json['DepartureTime']
+ except:
+ return -1
+
+
+url = 'http://api.trafikinfo.trafikverket.se/beta/data.json'
+headers = {'Content-Type': 'text/xml'}
+xml_data = """
+
+
+
+
+
+
+
+
+
+
+
+ DepartureTime
+ Info
+ ToHarbor.Id
+ ToHarbor.Name
+ FromHarbor.Name
+ FromHarbor.Id
+
+
+"""
+r = requests.post(url, data=xml_data, headers=headers)
+
+
+if r.status_code == 200:
+ data = r.json()
+
+ dataFerry = data['RESPONSE']['RESULT'][0]['FerryAnnouncement']
+
+ dataFerry.sort(key=extract_time, reverse=False)
+
+ result = []
+ for item in dataFerry:
+ mydict = {}
+ timestamp = item['DepartureTime']
+ timestamp = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S")
+ timestamp = timestamp.strftime("%H:%M:%S")
+ mydict['time'] = timestamp
+
+
+ if 'Info' in item:
+ info = unicode(item['Info'][0])
+ info = info.decode('UTF-8')
+ mydict['info'] = info
+
+ result.append(mydict)
+
+ print result
+
+
+else:
+ print "error"
+ print r.text
diff --git a/ferry/templates/index.html b/ferry/templates/index.html
index 3959837..dbd35b1 100644
--- a/ferry/templates/index.html
+++ b/ferry/templates/index.html
@@ -4,7 +4,6 @@
@@ -12,33 +11,28 @@
-
-
-
-
flash_on
-
Speeds up development
+
+
+
+
+ Tid
+ Från
+ Info
+
+
+ {% for value in data %}
+
+ {{ value['time'] }}
+ nånting
+ {% if 'info' in value %}
+ {{ value['info'] }}
+ {% else %}
+ nånting
+ {% endif %}
+
+ {% endfor %}
+
-
We did most of the heavy lifting for you to provide a default stylings that incorporate our custom components. Additionally, we refined animations and transitions to provide a smoother experience for developers.
-
-
-
-
-
-
group
-
User Experience Focused
-
-
By utilizing elements and principles of Material Design, we were able to create a framework that incorporates components and animations that provide more feedback to users. Additionally, a single underlying responsive system across all platforms allow for a more unified user experience.
-
-
-
-
-
-
settings
-
Easy to work with
-
-
We have provided detailed documentation as well as specific code examples to help new users get started. We are also always open to feedback and can answer any questions a user may have about Materialize.
-
-
@@ -50,9 +44,9 @@
-{% endblock %}
+ {% endblock %}
diff --git a/ferry/views.py b/ferry/views.py
index a914b0b..e5c0a47 100644
--- a/ferry/views.py
+++ b/ferry/views.py
@@ -1,43 +1,71 @@
from ferry.app import app
-from flask import render_template, request, jsonify
+from flask import render_template
import requests
-import pprint
+from datetime import datetime
@app.route('/')
@app.route('/index')
def index():
+ data = ferry_request()
+ print data
+ return render_template('index.html', data=data)
+
+
+def extract_time(json):
+
+ try:
+ return json['DepartureTime']
+ except:
+ return -1
- print ferry_request()
- return render_template('index.html')
def ferry_request():
url = 'http://api.trafikinfo.trafikverket.se/beta/data.json'
headers = {'Content-Type': 'text/xml'}
xml_data = """
-
-
-
-
-
-
-
-
-
-
-
-
- DepartureTime
- Info
- ToHarbor.Id
- ToHarbor.Name
- FromHarbor.Name
- FromHarbor.Id
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ DepartureTime
+ Info
+ ToHarbor.Id
+ ToHarbor.Name
+ FromHarbor.Name
+ FromHarbor.Id
+
+
"""
- r = requests.post(url, data=xml_data, headers=headers).json()
- print r
+ r = requests.post(url, data=xml_data, headers=headers)
- for i in r['RESPONSE']:
- print i
+ if r.status_code == 200:
+ data = r.json()
+ dataFerry = data['RESPONSE']['RESULT'][0]['FerryAnnouncement']
+ dataFerry.sort(key=extract_time, reverse=False)
+
+ result = []
+ for item in dataFerry:
+ mydict = {}
+ timestamp = item['DepartureTime']
+ timestamp = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S")
+ timestamp = timestamp.strftime("%H:%M:%S")
+ mydict['time'] = timestamp
+
+ if 'Info' in item:
+ info = item['Info'][0].encode('utf-8')
+ mydict['info'] = item['Info']
+
+ result.append(mydict)
+
+ return result
+ else:
+ return 0
diff --git a/requirements.txt b/requirements.txt
index 01a0f03..0c8fefd 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,93 +1,16 @@
-apsw==3.8.11.1.post1
-attrs==16.0.0
-BeautifulSoup==3.2.1
-beautifulsoup4==4.5.1
-blinker==1.3
-boto==2.40.0
-cffi==1.7.0
-characteristic==14.3.0
-chardet==2.3.0
-CherryPy==3.5.0
+appdirs==1.4.3
+backports-abc==0.5
+certifi==2017.4.17
click==6.7
-configobj==5.0.6
-cryptography==1.5
-cssselect==0.9.2
-cssutils==1.0
-debtags==2.0
-decorator==4.0.6
-defer==1.0.6
-dirspec==13.10
-dnspython==1.14.0
-dulwich==0.14.1
-duplicity==0.7.6
-enum34==1.1.6
-ExifRead==2.1.2
-fastimport==0.9.6
-feedparser==5.1.3
Flask==0.12.1
-html5lib==0.999
-httplib2==0.9.1
-idna==2.1
-ipaddress==1.0.16
-ipython==2.4.1
itsdangerous==0.24
Jinja2==2.9.6
-lockfile==0.12.2
-lxml==3.6.4
-Markdown==2.6.7
+livereload==2.5.1
MarkupSafe==1.0
-mechanize==0.2.5
-meld==3.16.3
-mutagen==1.34
-ndg-httpsclient==0.4.2
-netifaces==0.10.4
-oauthlib==1.1.2
-oneconf==0.3.9
-PAM==0.4.2
-pbr==1.8.1
-pexpect==4.2.0
-Pillow==3.3.1
-piston-mini-client==0.7.5
-Pivy==0.5.0
-ply==3.7
-ptyprocess==0.5.1
-pyasn1==0.1.9
-pyasn1-modules==0.0.7
-pycparser==2.14
-pycrypto==2.6.1
-pycups==1.9.73
-Pygments==2.1.3
-pygobject==3.22.0
-PyJWT==1.4.1
-pyOpenSSL==16.1.0
-pyparsing==2.1.8
-pyserial==3.1.1
-python-apt==1.1.0b5
-python-cloudfiles==1.7.10
-python-dateutil==2.4.2
-python-debian==0.1.29
-pyxdg==0.25
-PyYAML==3.11
-rabbitvcs==0.16.0
-repoze.lru==0.6
-requests==2.10.0
-Routes==2.2
-service-identity==16.0.0
-simplegeneric==0.8.1
-simplejson==3.8.2
+packaging==16.8
+pyparsing==2.2.0
+requests==2.13.0
+singledispatch==3.4.0.3
six==1.10.0
-software-center-aptd-plugins==0.0.0
-stevedore==1.10.0
-svtplay-dl==0.30.2016.1.10
-Twisted==16.4.1
-urllib3==1.15.1
-uTidylib==0.3
-vboxapi==1.0
-virtualenv==13.1.2
-virtualenv-clone==0.2.6
-virtualenvwrapper==4.7.1
-WebOb==1.6.1
+tornado==4.5.1
Werkzeug==0.12.1
-wxPython==3.0.2.0
-wxPython-common==3.0.2.0
-zope.interface==4.2.0