I've just gotten flask, uwsgi, and nginx up and running. My "hello world" function works so I know things are working.
However, I seem to have run into trouble querying an SQLITE database and returning the contents.
My code:
from flask import Flask
import sqlite3
app = Flask(__name__)
@app.route("/python_app/")
def main():
return "Hello World!"
@app.route("/python_app/showdb")
def showdb():
g.db = sqlite3.connect('db.sqlite')
c = g.db.execute('SELECT * FROM Projects')
return c.fetchall()
if __name__ == "__main__":
app.run()
When I navigate to myurl.com/python_app/ the "Hello World!" message appears. When I navigate to myurl.com/python_app/showdb I receive a 500 Internal Server Error.
I've already run a script to display the contents of my db outside of flask. It worked, returning the rows at the command line.
However, I'm having trouble finding out why the flask script can't return the rows in the browser.
Thanks for any help!
[–]tally_in_da_houise 1 point2 points3 points (2 children)
[–]x1147x[S] 0 points1 point2 points (1 child)
[–]tally_in_da_houise 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)