Я пытаюсь развернуть приложение фляги на эластичном бобовом стебле, и я получаю ошибку 500, когда пытаюсь получить к ней доступ. Я получаю следующий след из журнала ошибок:
mod_wsgi (pid=19748): Target WSGI script '/opt/python/current/app/application.py' cannot be loaded as Python module.
[Sat Jun 30 20:39:26.160095 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] mod_wsgi (pid=19748): Exception occurred processing WSGI script '/opt/python/current/app/application.py'.
[Sat Jun 30 20:39:26.160187 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] Traceback (most recent call last):
[Sat Jun 30 20:39:26.160228 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] File "/opt/python/current/app/application.py", line 107, in <module>
[Sat Jun 30 20:39:26.160232 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] @application.route("/signwriteragreement", methods=["POST"])
[Sat Jun 30 20:39:26.160238 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1250, in decorator
[Sat Jun 30 20:39:26.160241 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] self.add_url_rule(rule, endpoint, f, **options)
[Sat Jun 30 20:39:26.160246 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 66, in wrapper_func
[Sat Jun 30 20:39:26.160248 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] return f(self, *args, **kwargs)
[Sat Jun 30 20:39:26.160253 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] File "/opt/python/run/venv/local/lib/python3.6/site-packages/flask/app.py", line 1221, in add_url_rule
[Sat Jun 30 20:39:26.160256 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] 'existing endpoint function: %s' % endpoint)
[Sat Jun 30 20:39:26.160268 2018] [:error] [pid 19748] [remote 172.31.2.189:31160] AssertionError: View function mapping is overwriting an existing endpoint function: signwriteragreement
Мое приложение имеет следующий формат:
application.py
config.py
helpers.py
emailsupport.py
models.py
search.py
requirements.txt
/docs
(folders for saving documents)
/static
(static files)
/templates
(templates)
Я не забывал называть переменную своего приложения "application", так что это не проблема.
Вот начало application.py
from flask import Flask, render_template, redirect, url_for, request, session, flash, g, jsonify, render_template_string, send_from_directory, abort, Markup
application = Flask(__name__)
application.secret_key = "xxx"
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(application)
from itsdangerous import URLSafeTimedSerializer
from flask_wtf.csrf import CSRFProtect
from elasticsearch import Elasticsearch
csrf = CSRFProtect(application)
csrf.init_app(application)
UPLOAD_FOLDER = "/mnt/c/flasktest/repos/flasktestbackup/docs"
SHARED_FOLDER = UPLOAD_FOLDER + "/shared"
application.config["SQLALCHEMY_DATABASE_URI"] = "mysql+pymysql://xxx:xxx@xxx.cc8l5tq11szj.us-east-2.rds.amazonaws.com/xxx"
# ... (some other config stuff)... then
def login_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if session.get("user_id") is None:
return redirect("/welcome")
return f(*args, **kwargs)
return decorated_function
@application.route("/signwriteragreement", methods=["POST"])
@login_required
def signwriteragreement():
# rest of function
и внизу у меня есть:
if __name__ == '__main__':
application.debug = True
application.run()
Заранее благодарим за любую помощь, которую вы можете оказать