@ -1,30 +1,65 @@ |
|||
import csv |
|||
from flask import Flask, render_template |
|||
import sqlite3 |
|||
from flask import Flask, render_template, jsonify |
|||
|
|||
app = Flask(__name__) |
|||
|
|||
def load_pokemon_data(): |
|||
pokemon_list = [] |
|||
earliest_games = {} |
|||
|
|||
conn = sqlite3.connect('pokemon_database.db') |
|||
cursor = conn.cursor() |
|||
|
|||
# Load Pokemon Home list |
|||
with open('pokemon_home_list.csv', 'r') as file: |
|||
reader = csv.DictReader(file) |
|||
for row in reader: |
|||
pokemon_list.append(row) |
|||
cursor.execute(''' |
|||
SELECT p.national_dex_number, p.name, pf.form_name, pf.image_path, pf.is_default |
|||
FROM pokemon p |
|||
JOIN pokemon_forms pf ON p.national_dex_number = pf.pokemon_id |
|||
ORDER BY p.national_dex_number, pf.is_default DESC, pf.form_name |
|||
''') |
|||
|
|||
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 |
|||
}) |
|||
|
|||
# Load earliest games data |
|||
with open('pokemon_earliest_games.csv', 'r') as file: |
|||
reader = csv.DictReader(file) |
|||
for row in reader: |
|||
earliest_games[row['Pokemon']] = row['Earliest Game'] |
|||
|
|||
return pokemon_list, earliest_games |
|||
conn.close() |
|||
return pokemon_list |
|||
|
|||
@app.route('/') |
|||
def index(): |
|||
pokemon_list, earliest_games = load_pokemon_data() |
|||
return render_template('index.html', pokemon_list=pokemon_list, earliest_games=earliest_games) |
|||
pokemon_list = load_pokemon_data() |
|||
# 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__': |
|||
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 |