Я пытался развернуть свое приложение flask на веб-сервере apache и заставил его работать. Теперь я сталкиваюсь с проблемой, что на единственной странице, на которой мне нужно либо создать новую запись в моей базе данных (используя peewee sqlite для всех вещей, связанных с базой данных), либо внести изменения в уже захватывающую запись, я получаю 500 Internal Server Error.
Кажется, что он полностью функционирует при чтении базы данных, но не может записать в нее. Я обновил разрешения для файлов .db на 777, но это не помогло.
Следующий код находится в файле Flask и объявляет путь к файлу .db:
APP_DIR = os.path.dirname(os.path.realpath(__file__))
# Specifying the path of the DB file
DATABASE = 'sqliteext:///%s' % os.path.join(APP_DIR, 'blog.db')
Я разместил последний журнал ошибок ниже, это произошло при попытке создать новую запись, любые идеи очень ценятся.
[Sun Mar 01 15:59:58.008931 2020] [wsgi:error] [pid 5311:tid 139974393460480] [client 86.52.107.75:54947] hello: INDEX, referer: http://35.204.127.172/26-th/
[Sun Mar 01 15:59:58.010272 2020] [wsgi:error] [pid 5311:tid 139974393460480] [client 86.52.107.75:54947] totentries no search: 26, referer: http://35.204.127.172/26-th/
[Sun Mar 01 15:59:58.011008 2020] [wsgi:error] [pid 5311:tid 139974393460480] [client 86.52.107.75:54947] SELECT "t1"."id", "t1"."auth", "t1"."title", "t1"."slug", "t1"."content", "t1"."published", "t1"."timestamp" FROM "entry" AS "t1" WHERE ("t1"."published" = 1) ORDER BY "t1"."timestamp" DESC LIMIT 7 OFFSET 0, referer: http://35.204.127.172/26-th/
[Sun Mar 01 15:59:59.766531 2020] [wsgi:error] [pid 5311:tid 139974385067776] [client 86.52.107.75:54947] rasmus1, referer: http://35.204.127.172/index
[Sun Mar 01 15:59:59.767495 2020] [wsgi:error] [pid 5311:tid 139974385067776] [client 86.52.107.75:54947] entry 26, referer: http://35.204.127.172/index
[Sun Mar 01 16:00:02.433956 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] rasmus1, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.434670 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] entry 26, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.435722 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] 26, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439363 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] ERROR:FlaskApp:Exception on /26-th/ [POST], referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439380 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] Traceback (most recent call last):, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439384 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3057, in execute_sql, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439388 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] cursor.execute(sql, params or ()), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439391 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] sqlite3.OperationalError: unable to open database file, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439394 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] , referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439398 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] During handling of the above exception, another exception occurred:, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439401 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] , referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439404 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] Traceback (most recent call last):, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439407 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 2446, in wsgi_app, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439410 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] response = self.full_dispatch_request(), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439423 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1951, in full_dispatch_request, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439427 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] rv = self.handle_user_exception(e), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439429 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1820, in handle_user_exception, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439432 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] reraise(exc_type, exc_value, tb), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439435 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 39, in reraise, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439438 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] raise value, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439441 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1949, in full_dispatch_request, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439444 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] rv = self.dispatch_request(), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439447 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1935, in dispatch_request, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439450 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] return self.view_functions[rule.endpoint](**req.view_args), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439452 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 403, in detail, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439455 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] create_comment(slug), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439458 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/var/www/FlaskApp/FlaskApp/__init__.py", line 364, in create_comment, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439461 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] commentContent=request.form.get('comment'), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439464 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 6235, in create, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439466 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] inst.save(force_insert=True), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439469 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 6433, in save, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439472 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] pk = self.insert(**field_dict).execute(), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439475 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 1845, in inner, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439478 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] return method(self, database, *args, **kwargs), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439484 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 1916, in execute, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439487 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] return self._execute(database), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439490 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2665, in _execute, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439493 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] return super(Insert, self)._execute(database), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439496 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2400, in _execute, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439499 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] cursor = database.execute(self), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439501 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3070, in execute, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439504 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] return self.execute_sql(sql, params, commit=commit), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439507 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3064, in execute_sql, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439510 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] self.commit(), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439513 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2831, in __exit__, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439515 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] reraise(new_type, new_type(exc_value, *exc_args), traceback), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439518 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 183, in reraise, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439521 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] raise value.with_traceback(tb), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439524 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3057, in execute_sql, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439527 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] cursor.execute(sql, params or ()), referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439531 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] peewee.OperationalError: unable to open database file, referer: http://35.204.127.172/26-th/
[Sun Mar 01 16:00:02.439547 2020] [wsgi:error] [pid 5311:tid 139974376675072] [client 86.52.107.75:54947] , referer: http://35.204.127.172/26-th/
РЕДАКТИРОВАТЬ: Решено комментарием