Permalink
Browse files

flaskifying shit

  • Loading branch information...
1 parent 5db840b commit d46f56b0378a1c565579603da5cfcad6f5ab4f07 @RenardHJ RenardHJ committed Feb 17, 2017
Showing with 34 additions and 5 deletions.
  1. +30 −2 server.py
  2. +4 −3 templates/charts.html
View
@@ -1,7 +1,7 @@
import os
from datetime import datetime
-from flask import Flask, render_template
+from flask import Flask, render_template, Markup
from flask_socketio import SocketIO, emit
app = Flask(__name__)
@@ -22,7 +22,35 @@ def search(query):
@app.route("/")
def mainIndex():
- return render_template('charts.html')
+ if request.method == 'POST':
+ search = request.form['search']
+ else:
+ search = "Virginia Beach"
+
+ # get info for search here
+
+ qualityOfLife='10%'
+
+ buttonItems = [
+ {'action': '/test', 'icon': 'fa fa-cutlery' , 'title' : 'Restauraunt'},
+ {'action': '/test2', 'icon': 'fa fa-shopping-bag' , 'title' : 'Shopping'},
+ {'action': '/test3', 'icon': 'fa fa-glass' , 'title' : 'Night Life'},
+ {'action': '/test4', 'icon': 'fa fa-car' , 'title' : 'Travel'},
+ {'action': '/test5', 'icon': 'fa fa-house' , 'title' : 'Housing'},
+ {'action': '/test6', 'icon': 'fa fa-stop' , 'title' : 'Safety'}
+ ]
+
+ data = [
+ {'value':'10','content':'1 ' + Markup('<span class="fa fa-star"></span>')},
+ {'value':'20','content':'2 ' + Markup(' <span class="fa fa-star"></span><span class="fa fa-star"></span>')},
+ {'value':'30','content':'3 ' + Markup('<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>')},
+ {'value':'20','content':'4 ' + Markup('<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>')},
+ {'value':'10','content':'5 ' + Markup('<span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span>')}
+ ]
+
+ location = 'Brooklyn+Bridge,New+York,NY';
+
+ return render_template('charts.html', livingQuality=qualityOfLife, buttons=buttonItems, data = data, location = location)
if __name__ == "__main__":
socketio.run(app, host=os.getenv("IP", "0.0.0.0"), port=int(os.getenv("PORT", 8080)), debug=True)
@@ -53,9 +53,10 @@
<li data-value="{{ data[2] }}">4 <span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span></li>
<li data-value="{{ data[3] }}">3 <span class="fa fa-star"></span><span class="fa fa-star"></span><span class="fa fa-star"></span></li>
<li data-value="{{ data[4] }}">2 <span class="fa fa-star"></span><span class="fa fa-star"></span></li>
+
<li data-value="{{ data[5] }}">1 <span class="fa fa-star"></span></li>
-->
- <li data-value="{{ results[value] }}">{{ results[content] }}</li>
+ <li data-value="{{ results['value'] }}">{{ results['content'] }}</li>
{% endfor %}
</ul>
</div>
@@ -66,8 +67,8 @@
<div class="btn-group btn-group-justified" role="group" aria-label="...">
{% for item in buttons %}
<div class="btn-group" role="group">
- <form method="post" action="{{ item[action] }}">
- <button type="submit" class="btn-default"><span class="{{ item[icon] }}"></span> {{ item[title] }}
+ <form method="post" action="{{ item['action'] }}">
+ <button type="submit" class="btn btn-default"><span class="{{ item['icon'] }}"></span> {{ item['title'] }}
</form>
</div>
{% endfor %}

0 comments on commit d46f56b

Please sign in to comment.