-
Notifications
You must be signed in to change notification settings - Fork 7
/
app.py
33 lines (24 loc) · 771 Bytes
/
app.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
30
31
32
33
from flask import Flask, Response, render_template, request
import json
from wtforms import TextField, Form
app = Flask(__name__)
cities = ["Bratislava",
"Banská Bystrica",
"Prešov",
"Považská Bystrica",
"Žilina",
"Košice",
"Ružomberok",
"Zvolen",
"Poprad"]
class SearchForm(Form):
autocomp = TextField('Insert City', id='city_autocomplete')
@app.route('/_autocomplete', methods=['GET'])
def autocomplete():
return Response(json.dumps(cities), mimetype='application/json')
@app.route('/', methods=['GET', 'POST'])
def index():
form = SearchForm(request.form)
return render_template("search.html", form=form)
if __name__ == '__main__':
app.run(debug=True)