@ -1,30 +1,65 @@ |
|||||
import csv |
import sqlite3 |
||||
from flask import Flask, render_template |
from flask import Flask, render_template, jsonify |
||||
|
|
||||
app = Flask(__name__) |
app = Flask(__name__) |
||||
|
|
||||
def load_pokemon_data(): |
def load_pokemon_data(): |
||||
pokemon_list = [] |
pokemon_list = [] |
||||
earliest_games = {} |
|
||||
|
|
||||
# Load Pokemon Home list |
conn = sqlite3.connect('pokemon_database.db') |
||||
with open('pokemon_home_list.csv', 'r') as file: |
cursor = conn.cursor() |
||||
reader = csv.DictReader(file) |
|
||||
for row in reader: |
|
||||
pokemon_list.append(row) |
|
||||
|
|
||||
# Load earliest games data |
cursor.execute(''' |
||||
with open('pokemon_earliest_games.csv', 'r') as file: |
SELECT p.national_dex_number, p.name, pf.form_name, pf.image_path, pf.is_default |
||||
reader = csv.DictReader(file) |
FROM pokemon p |
||||
for row in reader: |
JOIN pokemon_forms pf ON p.national_dex_number = pf.pokemon_id |
||||
earliest_games[row['Pokemon']] = row['Earliest Game'] |
ORDER BY p.national_dex_number, pf.is_default DESC, pf.form_name |
||||
|
''') |
||||
|
|
||||
return pokemon_list, earliest_games |
for row in cursor.fetchall(): |
||||
|
national_dex_number, name, form_name, image_path, is_default = row |
||||
|
|
||||
|
pokemon_list.append({ |
||||
|
'ID': national_dex_number, |
||||
|
'Name': name, |
||||
|
'Form': form_name, |
||||
|
'Image': image_path, |
||||
|
'IsDefault': is_default |
||||
|
}) |
||||
|
|
||||
|
conn.close() |
||||
|
return pokemon_list |
||||
|
|
||||
@app.route('/') |
@app.route('/') |
||||
def index(): |
def index(): |
||||
pokemon_list, earliest_games = load_pokemon_data() |
pokemon_list = load_pokemon_data() |
||||
return render_template('index.html', pokemon_list=pokemon_list, earliest_games=earliest_games) |
# Create a list of lists, each inner list containing up to 30 Pokémon forms |
||||
|
grouped_pokemon = [pokemon_list[i:i+30] for i in range(0, len(pokemon_list), 30)] |
||||
|
return render_template('index.html', grouped_pokemon=grouped_pokemon) |
||||
|
|
||||
|
@app.route('/pokemon/<int:dex_number>') |
||||
|
def pokemon_details(dex_number): |
||||
|
conn = sqlite3.connect('pokemon_database.db') |
||||
|
cursor = conn.cursor() |
||||
|
|
||||
|
cursor.execute(''' |
||||
|
SELECT pf.form_name, g.name, l.name, em.name |
||||
|
FROM form_encounters fe |
||||
|
JOIN games g ON fe.game_id = g.id |
||||
|
JOIN locations l ON fe.location_id = l.id |
||||
|
JOIN encounter_methods em ON fe.encounter_method_id = em.id |
||||
|
JOIN pokemon_forms pf ON fe.form_id = pf.id |
||||
|
WHERE pf.pokemon_id = ? |
||||
|
ORDER BY pf.is_default DESC, pf.form_name, g.generation, g.name, l.name |
||||
|
''', (dex_number,)) |
||||
|
|
||||
|
encounters = [ |
||||
|
{'form': form, 'game': game, 'location': location, 'method': method} |
||||
|
for form, game, location, method in cursor.fetchall() |
||||
|
] |
||||
|
|
||||
|
conn.close() |
||||
|
return jsonify(encounters) |
||||
|
|
||||
if __name__ == '__main__': |
if __name__ == '__main__': |
||||
app.run(debug=True) |
app.run(debug=True) |
||||
|
|||||
@ -1,43 +0,0 @@ |
|||||
<!DOCTYPE html> |
|
||||
<html lang="en"> |
|
||||
<head> |
|
||||
<meta charset="UTF-8"> |
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
||||
<title>OriginDex - Pokémon Tracker</title> |
|
||||
<style> |
|
||||
table { |
|
||||
border-collapse: collapse; |
|
||||
width: 100%; |
|
||||
} |
|
||||
th, td { |
|
||||
border: 1px solid black; |
|
||||
padding: 8px; |
|
||||
text-align: left; |
|
||||
} |
|
||||
th { |
|
||||
background-color: #f2f2f2; |
|
||||
} |
|
||||
</style> |
|
||||
</head> |
|
||||
<body> |
|
||||
<h1>OriginDex - Pokémon Tracker</h1> |
|
||||
<table> |
|
||||
<thead> |
|
||||
<tr> |
|
||||
<th>Pokémon</th> |
|
||||
<th>Earliest Game</th> |
|
||||
<th>Caught</th> |
|
||||
</tr> |
|
||||
</thead> |
|
||||
<tbody> |
|
||||
{% for pokemon in pokemon_list %} |
|
||||
<tr> |
|
||||
<td>{{ pokemon.Pokemon }}</td> |
|
||||
<td>{{ earliest_games.get(pokemon.Pokemon, 'Unknown') }}</td> |
|
||||
<td><input type="checkbox" name="caught" value="{{ pokemon.Pokemon }}"></td> |
|
||||
</tr> |
|
||||
{% endfor %} |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</body> |
|
||||
</html> |
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1005 B |
|
After Width: | Height: | Size: 789 B |
|
After Width: | Height: | Size: 749 B |
|
After Width: | Height: | Size: 780 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 959 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 9.8 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 9.5 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 9.9 KiB |
|
After Width: | Height: | Size: 7.8 KiB |
|
After Width: | Height: | Size: 8.9 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |