Skip to content

Instantly share code, notes, and snippets.

@elseagle
Last active May 25, 2019 03:30
Show Gist options
  • Save elseagle/bed782e2d28a61d9fc8870b89548fbe4 to your computer and use it in GitHub Desktop.
Save elseagle/bed782e2d28a61d9fc8870b89548fbe4 to your computer and use it in GitHub Desktop.
@app.route('/item')
def get():
connection = sqlite3.connect('data.db')
cursor = connection.cursor()
query = "SELECT * FROM items"
result = cursor.execute(query)
items = []
for row in result:
items.append({'name': row[0], 'price': row[1]})
connection.close()
return jsonify({'items': items})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment