Howdy everyone,
I'm trying to get some info on how to fix a little issue I'm having. I have a database I'm trying to pull information from with sqlite3. Everything I do works great locally but for some reason it does't translate when I post it here. I have a beginner account but I can't find anywhere that that would be an issue (if it is then great! at least I'll know the problem).
The url is tlamanna42.pythonanywhere.com/sqltest
And the main app:
# A very simple Flask Hello World app for you to get started with...f
from functions1 import Test
import urllib
from flask import Flask, render_template, g
import sqlite3
app = Flask(__name__)
app.secret_key = "my precious"
app.database = "posts.db"
x = Test()
y = urllib.urlopen('http://www.google.com')
z = y.read()
@app.route('/')
def hello_world():
return 'Hello from Flask!'
@app.route('/test')
def test():
return 'Test'
@app.route('/111')
def xxx():
return x.test()
@app.errorhandler(404)
def error(e):
return 'No'
@app.route('/urllib')
def xxxx():
return z
@app.route('/sqltest')
def sqltest():
g.db = connect_db()
cur = g.db.execute('select * from posts')
posts1 = [dict(title=row[0],description=row[1]) for row in cur.fetchall()]
g.db.close()
return render_template('sqltest.html', posts1=posts1)
@app.route('/welcome')
def welcome():
post = 'post'
return render_template('welcome.html', post=post)
def connect_db():
return sqlite3.connect(app.database)
if __name__ == '__main__':
app.run(debug=True)
Thank you so much.