Browse Source

Add featured to index page

marches
Josh Gordon 3 years ago
parent
commit
31b94e5069
  1. 11
      app/routes.py
  2. 18
      app/templates/index.html

11
app/routes.py

@ -5,6 +5,8 @@ from flask import request
from items import get_items
from items import get_spells
from random import choice
app = Flask(__name__)
@app.route('/style.css')
@ -13,7 +15,14 @@ def style():
@app.route('/')
def index():
return render_template('index.html')
featureType = choice(["Item","Place","Spell"])
item = None
if(featureType == "Spell"):
item = choice(get_spells())
else:
item = choice(get_items("../"+featureType+"s/*"))
return render_template('index.html',featureType=featureType,featureText=item)
@app.route('/items')
def items():

18
app/templates/index.html

@ -15,5 +15,23 @@
<li><a href="/spells">Spells</a></li>
</ul>
</nav>
<section>
<h2>Featured {{featureType}}:</h2>
{% if featureType == "Spell" %}
<table>
<tr>
<td>{{featureText[0]}}</td>
<td>{{featureText[2]}}</td>
</tr>
</table>
{% else %}
<table>
<tr>
<td>{{featureText[0]}}</td>
<td>{{featureText[1]}}</td>
</tr>
</table>
{% endif %}
</section>
</body>
</html>
Loading…
Cancel
Save