-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.py
29 lines (23 loc) · 812 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os, time
from flask import Flask, Response, render_template, jsonify
from geojson import Point, Feature, FeatureCollection
app = Flask(__name__)
app.debug = True
ACCESS_KEY = os.environ.get('MAPBOX_ACCESSKEY')
@app.route('/')
def index():
return render_template('index.html', ACCESS_KEY=ACCESS_KEY)
@app.route('/result')
def process():
point = Point((-77.0366048812866, 38.89784666877921))
feature = Feature(geometry=point)
feature_collection = FeatureCollection([feature])
return jsonify(result=feature_collection)
@app.route('/process')
def long_running_process():
def generate():
for row in range(1, 10):
yield 'data: Processing \n\n'
time.sleep(2)
return Response(generate(), mimetype='text/event-stream')
app.run(threaded=True)