6/23/2023 0 Comments Host flask sqlite![]() ![]() ![]() The first thing we do in the API is create the Flask app and import the games controller.2020 - 05 - 21 21 : 07 : 56, 189 : Error running WSGI application 2020 - 05 - 21 21 : 07 : 56, 201 : AttributeError: ' NoneType ' object has no attribute ' drivername ' 2020 - 05 - 21 21 : 07 : 56, 201 : File "/home/eczeno/.virtualenvs/env/lib/python3.8/site-packages/flask/app.py", line 2464, in _call_ 2020 - 05 - 21 21 : 07 : 56, 202 : return self. ![]() Now that we have the CRUD of the operations with the database, it is time to expose everything in the API with Flask. Note that all functions use the database and a cursor to perform all operations. We also see other methods such as update_game that performs the UPDATE operation to update a game, delete_game that deletes a game ( DELETE) from its id, get_by_id that returns a game from its id (using the SELECT operation).įinally we look at the get_games function that returns all existing games. The insert_game function receives the game data and inserts it into the database ( INSERT) all this using prepared statements to avoid SQL injections in this API that we are creating with Python and Flask. ![]()
0 Comments
Leave a Reply. |