Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
acharyasourav committed Jul 23, 2022
0 parents commit 9b8f8f4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from flask import Flask, render_template, request, send_file
from geopy.geocoders import ArcGIS
import pandas
import datetime

app=Flask(__name__)

@app.route("/")
def index():
return render_template("index.html")

@app.route('/success-table', methods=['POST'])
def success_table():
global filename
if request.method=="POST":
file=request.files['file']
try:
df=pandas.read_csv(file)
gc=ArcGIS(scheme='http')
df["coordinates"]=df["Address"].apply(gc.geocode)
df['Latitude'] = df['coordinates'].apply(lambda x: x.latitude if x != None else None)
df['Longitude'] = df['coordinates'].apply(lambda x: x.longitude if x != None else None)
df=df.drop("coordinates",1)
filename=datetime.datetime.now().strftime("sample_files/%Y-%m-%d-%H-%M-%S-%f"+".csv")
df.to_csv(filename,index=None)
return render_template("index.html", text=df.to_html(), btn='download.html')
except Exception as e:
return render_template("index.html", text=str(e))

@app.route("/download-file/")
def download():
return send_file(filename, attachment_filename='yourfile.csv', as_attachment=True)

if __name__=="__main__":
app.run(debug=True)

0 comments on commit 9b8f8f4

Please sign in to comment.