0% found this document useful (0 votes)
16 views2 pages

Flask Folium

The document defines a Flask web application that renders templates displaying Pandas DataFrames extracted from Excel files on routes. It includes routes for an emission form, processing submitted text, and displaying male and female data tables.

Uploaded by

Suman Senapati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Flask Folium

The document defines a Flask web application that renders templates displaying Pandas DataFrames extracted from Excel files on routes. It includes routes for an emission form, processing submitted text, and displaying male and female data tables.

Uploaded by

Suman Senapati
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

from flask import Flask, request, render_template

import pandas as pd
import folium

app = Flask(__name__)

@app.route('/')
def emission_form():
return render_template('emission-form.html')

def index():
start_coords = (46.9540700, 142.7360300)
folium_map = folium.Map(location=start_coords, zoom_start=14)
return folium_map._repr_html_()

@app.route('/', methods=['POST'])
def emission_form_post():
text = request.form['text']
df = pd.read_excel('DESMO.xlsx')

# Drop first column of dataframe


df = df.iloc[:, 1:]
print(df[df['IMONumber'] == int(text)])

processed_text = text.upper()

start_coords = (46.9540700, 142.7360300)


folium_map = folium.Map(location=start_coords, zoom_start=14)
return processed_text, folium_map._repr_html_()

@app.route('/tables')
def show_tables():
data = pd.read_excel('dummy_data.xlsx')
data.set_index(['Name'], inplace=True)
data.index.name=None
females = data.loc[data.Gender=='f']
males = data.loc[data.Gender=='m']
return render_template('view.html',tables=[females.to_html(classes='female'),
males.to_html(classes='male')],
titles = ['na', 'Female surfers', 'Male surfers'])

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

import folium
import pandas as pd
from flask import Flask, render_template

app = Flask(__name__)

@app.route("/", methods=["GET"])
def status():
print("/")
return "Status: OK"

@app.route("/map", methods=["GET"])
def map():
print("/map")
return render_template("mymap.html")
# return(my_map.get_root().render())

def generate_map():
df = pd.read_csv("coordinates.csv")

my_map = folium.Map(
# center: Hong Kong Space Museum
location=[22.295403586726987, 114.17205382336623],
tiles='cartodbpositron',
zoom_start=13
)
df.apply(lambda row:folium.Marker(location=[row["Latitude"], row["Longitude"]],
popup=row["Location"], icon=folium.Icon(color='red', prefix='fa fa-circle-
o')).add_to(my_map), axis=1)
my_map.save("templates/mymap.html")

if __name__=="__main__":
generate_map()
print("Map is generated")

app.run(host="0.0.0.0", port=4000, debug=True)

You might also like