Skip to content

Commit 7af5469

Browse files
last changes to api
1 parent e2e7840 commit 7af5469

File tree

2 files changed

+48
-31
lines changed

2 files changed

+48
-31
lines changed

hackathon.py

+46-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
from flask import Flask
1+
from flask import Flask, jsonify, Response
22
from flask.ext.restless import APIManager
33
from flask.ext.sqlalchemy import SQLAlchemy
44
from flask_admin import Admin
55
from flask_admin.contrib.sqla import ModelView
6+
import os
7+
from suds.client import Client
8+
import logging
9+
import datetime
10+
import json
11+
from flask_cors import CORS
612

13+
port = os.getenv('PORT', '4999')
714
app = Flask(__name__)
815

916
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db'
1017
db = SQLAlchemy(app)
18+
CORS(app)
1119
admin = Admin(app, name='pingins', template_mode='bootstrap3')
1220
app.secret_key='daahackathon'
1321

@@ -27,5 +35,41 @@ class User(db.Model):
2735
api_manager = APIManager(app, flask_sqlalchemy_db=db)
2836
api_manager.create_api(User, methods=['GET', 'POST', 'DELETE', 'PUT'])
2937

38+
username = 'headbroken'
39+
apiKey = '2428b712a94d4e1489340da6da32625791ad6e8d'
40+
url = 'http://flightxml.flightaware.com/soap/FlightXML2/wsdl'
41+
42+
# This is a custom HTTP transport that allows Basic Authentication.
43+
logging.basicConfig(level=logging.INFO)
44+
api = Client(url, username=username, password=apiKey)
45+
46+
@app.route("/flightapi")
47+
def hello():
48+
49+
# print api
50+
51+
# Get the weather
52+
result = api.service.Metar('KAUS')
53+
54+
# Get the flights enroute
55+
result = api.service.Scheduled('EIDW', 10, '', 0)
56+
flights = result['scheduled']
57+
flightlisting = []
58+
flightdict = {}
59+
flightsdict = {}
60+
for flight in flights:
61+
flightdict = {}
62+
flightdict['flightnumber'] = flight['ident']
63+
flightdict['destinationName'] =flight['destinationName']
64+
flightdict['estimatedarrivaltime'] = flight['estimatedarrivaltime']
65+
flightdict['filed_departuretime'] = flight['filed_departuretime']
66+
#flightsdict[flight['ident']] = flightdict
67+
flightlisting.append(flightdict)
68+
flightlisting.append(flightsdict)
69+
resp = Response(response=json.dumps(flightlisting),
70+
status=200,
71+
mimetype="application/json")
72+
return resp
73+
3074
if __name__ == "__main__":
31-
app.run('0.0.0.0', port=80)
75+
app.run('0.0.0.0', port=int(port))

requirements.txt

+2-29
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,16 @@ Flask-RESTful==0.3.5
55
Flask-Restless==0.17.0
66
Flask-SQLAlchemy==2.1
77
Jinja2==2.8
8-
Landscape-Client==14.12
98
MarkupSafe==0.23
10-
PAM==0.4.2
119
PyYAML==3.10
1210
SQLAlchemy==1.0.12
13-
Twisted-Core==13.2.0
14-
Twisted-Names==13.2.0
15-
Twisted-Web==13.2.0
1611
WTForms==2.1
1712
Werkzeug==0.11.7
1813
aniso8601==1.1.0
19-
apt-xapian-index==0.45
2014
argparse==1.2.1
21-
chardet==2.0.1
22-
cloud-init==0.7.5
2315
colorama==0.2.5
2416
configobj==4.7.2
2517
html5lib==0.999
2618
itsdangerous==0.24
27-
jsonpatch==1.3
28-
jsonpointer==1.0
29-
mimerender==0.6.0
30-
oauth==1.0.1
31-
prettytable==0.7.2
32-
pyOpenSSL==0.13
33-
pycurl==7.19.3
34-
pyserial==2.6
35-
python-apt==0.9.3.5ubuntu1
36-
python-dateutil==2.5.2
37-
python-debian==0.1.21-nmu2ubuntu2
38-
python-mimeparse==1.5.1
39-
pytz==2016.3
40-
requests==2.2.1
41-
six==1.5.2
42-
ssh-import-id==3.21
43-
urllib3==1.7.1
44-
virtualenv==15.0.1
45-
wheel==0.24.0
46-
wsgiref==0.1.2
47-
zope.interface==4.0.5
19+
suds==0.4
20+
Flask-Cors==2.1.2

0 commit comments

Comments
 (0)