Помогите пожалуйста исправить ошибку Internal Server Error при деплое на pythonanywhere.
При запуске на локальном сервере все работает. Тут возникают ошибки.
Пользовался инструкцией:
https://ichi.pro/ru/kak-besplatno-razmestit-priloz...
В error log пишет:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: item
[SQL: SELECT item.id AS item_id, item.title AS item_title, item.price AS item_price, item.about AS item_about, item.size AS item_size, item.src AS item_src, item.link AS item_link, item."isActive" AS "item_isActive"
FROM item]
Код
from flask import render_template, request, redirect
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///shop.db '
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
class Item(db.Model):
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(50), nullable=False)
price = db.Column(db.String(5), nullable=False)
about = db.Column(db.Text, nullable=False)
size = db.Column(db.String(50), nullable=False)
src = db.Column(db.Text, nullable=False)
link = db.Column(db.Text, nullable=False)
isActive = db.Column(db.Boolean, nullable=True)
def __repr__(self):
return self.title
@app.route('/')
@app.route('/index', methods=['GET', 'POST'])
def index_test():
items = Item.query.all() # Можно добавить сортировку .order_by(Item.name).
return render_template('index.html', db=items)
@app.route('/create', methods=['GET', 'POST'])
def create():
if request.method == "POST":
title = request.form['title']
price = request.form['price']
about = request.form['about']
size = request.form['size']
src = request.form['src']
link = request.form['link']
item = Item(
title=title,
price=price,
about=about,
size=size,
src=src,
link=link)
try:
db.session.add(item)
db.session.commit()
return redirect('/index')
except Warning:
return "Something is going wrong"
else:
return render_template('create.html')
@app.route('/about_us', methods=['GET', 'POST'])
def about_us():
return render_template('about.html')