Skip to content

Commit

Permalink
layers, refactoring, performance
Browse files Browse the repository at this point in the history
  • Loading branch information
gpivaro committed Dec 15, 2020
1 parent 8fd06eb commit 7e15546
Show file tree
Hide file tree
Showing 6 changed files with 1,681 additions and 49 deletions.
50 changes: 1 addition & 49 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from flask import Flask, jsonify, render_template, url_for
from sqlalchemy import create_engine
# from flask_sqlalchemy import SQLAlchemy
import pandas as pd
import os
import json
Expand All @@ -17,7 +16,6 @@
pass



# Database name and database tables
database_name = "project_2"
table_airplanes = "aircraft_data"
Expand All @@ -40,27 +38,16 @@
app = Flask(__name__)


# # SQLite for performance reason
# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///site.db'
# db = SQLAlchemy(app)


#################################################
# Flask Routes
#################################################
# Use Flask to create your routes.

# Route

# Home page.
@app.route("/")
def welcome():
return render_template("index_Gabriel_v3.html")
return render_template("index_Gabriel_v4.html")

# Home page.
@app.route("/aircrafts")
def aircraft_analysis():
return render_template("icao24_View_Gabriel.html")

# Home page.
@app.route("/sarah")
Expand Down Expand Up @@ -204,41 +191,6 @@ def api_aircrafts_byhour():
parsed = json.loads(result)
return jsonify(parsed)



# # Return a json with the query results for the aircraft table
# @app.route("/api/v1.0/aircraft-icao24/<icao24>")
# def api_aircraft_data(icao24):

# df = pd.read_sql(f"""
# SELECT
# *
# FROM
# {table_airplanes}
# WHERE
# longitude IS NOT NULL
# AND
# icao24 = '{icao24}';
# """,
# engine)

# # Calculate the distance between two coordinates
# df['distance_traveled'] = ''
# for index,row in df.iterrows():
# # print((row['latitude'],row['longitude']))
# try:
# coords_1 = (df['latitude'].iloc[index],df['longitude'].iloc[index])
# coords_2 = ((df['latitude'].iloc[index+1],df['longitude'].iloc[index+1]))
# distance_mi = round(geopy.distance.geodesic(coords_1, coords_2).mi*10)/10
# df['distance_traveled'].iloc[index] = distance_mi
# except:
# pass

# result = df.to_json(orient="records")
# parsed = json.loads(result)
# return jsonify(parsed)


# The server is set to run on the computer IP address on the port 5100
# Go to your http://ipaddress:5100
if __name__ == "__main__":
Expand Down
Binary file added static/images/favicon.ico
Binary file not shown.
Loading

0 comments on commit 7e15546

Please sign in to comment.