Skip to content

Commit

Permalink
added prefix method
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-howlett-sonarsource committed Apr 7, 2024
1 parent c39f45d commit a30f89a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pokedex/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def get_pokemon(pokemon_id: str):
)
except:
return redirect(url_for("index"))

#add a route that calls prefix_pokemon_name
@app.route("/prefix/<name>")
def prefix_name(name):
prefix = request.args.get("prefix")
return helper.prefix_pokemon_name(name, prefix)



def get_db():
Expand Down
4 changes: 4 additions & 0 deletions pokedex/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def fetch_pokemon_by_start(wrapper: ConnectionWrapper, start_letter: str):
statement = f"SELECT * FROM POKEDEX WHERE name LIKE '{start_letter}%'"
return wrapper.__conn.execute(statement).fetchall()

#add a method to prefix a pokemon name with a given string and return the new name
def prefix_pokemon_name(name: str, prefix: str):
return prefix + name


def register_subscriber(wrapper: ConnectionWrapper, email):
pattern = re.compile(r"(.*)@(.*\..*)")
Expand Down

0 comments on commit a30f89a

Please sign in to comment.