몇 주 동안 Flask 앱을 개발했습니다. 나는 오늘 그것을 끝내고 배포하려고했지만 이제는 시작되지 않습니다.
코드를 추가하거나 제거하지 않았으므로 배포 프로세스에서 변경된 내용이 있다고 가정합니까?
어쨌든 다음은 터미널에 표시되는 전체 오류입니다.
Traceback (most recent call last):
File "C:\Users\Kev\Documents\Projects\Docket\manage.py", line 5, in <module>
from app import create_app, db
File "C:\Users\Kev\Documents\Projects\Docket\app\__init__.py", line 21, in <module>
from app.api import api, blueprint, limiter
File "C:\Users\Kev\Documents\Projects\Docket\app\api\__init__.py", line 2, in <module>
from flask_restplus import Api
File "C:\Users\Kev\.virtualenvs\Docket-LasDxOWU\lib\site-packages\flask_restplus\__init_
_.py", line 4, in <module>
from . import fields, reqparse, apidoc, inputs, cors
File "C:\Users\Kev\.virtualenvs\Docket-LasDxOWU\lib\site-packages\flask_restplus\fields.
py", line 17, in <module>
from werkzeug import cached_property
ImportError: cannot import name 'cached_property' from 'werkzeug' (C:\Users\Kev\.virtualen
vs\Docket-LasDxOWU\lib\site-packages\werkzeug\__init__.py)
또한 여기 언급 된 세 파일의 코드가 있습니다.
manage.py
:
from apscheduler.schedulers.background import BackgroundScheduler
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import create_app, db
app = create_app()
app.app_context().push()
manager = Manager(app)
migrate = Migrate(app, db)
manager.add_command('db', MigrateCommand)
from app.routes import *
from app.models import *
def clear_data():
with app.app_context():
db.session.query(User).delete()
db.session.query(Todo).delete()
db.session.commit()
print("Deleted table rows!")
@manager.command
def run():
scheduler = BackgroundScheduler()
scheduler.add_job(clear_data, trigger='interval', minutes=15)
scheduler.start()
app.run(debug=True)
if __name__ == '__main__':
clear_data()
manager.run()
app/__init__.py
:
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from config import Config
db = SQLAlchemy()
login = LoginManager()
def create_app():
app = Flask(__name__)
app.config.from_object(Config)
db.init_app(app)
login.init_app(app)
login.login_view = 'login'
from app.api import api, blueprint, limiter
from app.api.endpoints import users, todos, register
from app.api.endpoints.todos import TodosNS
from app.api.endpoints.users import UserNS
from app.api.endpoints.register import RegisterNS
api.init_app(app)
app.register_blueprint(blueprint)
limiter.init_app(app)
api.add_namespace(TodosNS)
api.add_namespace(UserNS)
api.add_namespace(RegisterNS)
return app
api/__init__.py
:
from logging import StreamHandler
from flask_restplus import Api
from flask import Blueprint
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
blueprint = Blueprint('api', __name__, url_prefix='/api')
limiter = Limiter(key_func=get_remote_address)
limiter.logger.addHandler(StreamHandler())
api = Api(blueprint, doc='/documentation', version='1.0', title='Docket API',
description='API for Docket. Create users and todo items through a REST API.\n'
'First of all, begin by registering a new user via the registration form in the web interface.\n'
'Or via a `POST` request to the `/Register/` end point', decorators=[limiter.limit("50/day", error_message="API request limit has been reached (50 per day)")])
나는 다시 설치 해봤 flask
및 flask_restplus
하지만 운을.
Python 3.8에서는 다음을 수행 할 수 있습니다.
—
Martin Thoma
from functools import cached_property
flask-restx
하거나 고정하려고 할 수Werkzeug==0.16.1
있습니다.