a-luna / aaronluna.dev

My personal website/blog/portfolio, built with Hugo
https://aaronluna.dev
3 stars 1 forks source link

series/flask-api-tutorial/part-1/ #64

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

How To: Create a Flask API with JWT-Based Authentication (Part 1) - aaronluna.dev

In Part 1, the core concepts of REST and JWTs are introduced, project dependencies are described and installed, and the project is fully configured for prod/dev environments. The flask server and CLI are demonstrated to ensure the setup was performed correctly before moving on to Part 2.

https://aaronluna.dev/series/flask-api-tutorial/part-1/

BrenoAlberto commented 4 years ago

One of the best tutorials I've ever seen!

a-luna commented 4 years ago

BrenoAlberto - Thank you!

rlsteelman commented 2 years ago

When running tox for the first time, you might encounter an issue with MarkupSafe and soft_unicode. A minor release of the package broke core functionality as noted here: https://github.com/pallets/markupsafe/issues/286

The first fix is to specify a version of MarkupSafe>=2.0.1 in your setup.py script. I just added it to the end of the INSTALL_REQUIRES.

The second issue is with Jinja2. Even when I specified in setup.py for Jinja2 to be version >=3.0.3, tox would still fail. The reason is that tox was running an older version by default, and the fix for the above issue is in Jinja2>=3.0.3.

In tox.ini at the end of the deps = list, just add jinja2>=3.0.3

Now, when you run tox it will be fixed.

https://quadrabyte.net/

vikacisys commented 2 years ago

Thanks for the wonderful tutorial. I am using Python 3.10. Changed version in pyproject.toml, tox.ini & .pre-commit-config.yaml. It gives this error. flake8 version is 4.0.1

======================================================================== short test summary info ========================================================================= SKIPPED [13] .tox/py310/lib/python3.10/site-packages/pytest_black.py:67: file(s) previously passed black format checks FAILED run.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED setup.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/config.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/api/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/api/auth/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/api/widgets/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/models/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/util/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/util/datetime_util.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED src/flask_api_tutorial/util/result.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED tests/init.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' FAILED tests/testconfig.py::flake-8::FLAKE8 - AttributeError: module 'flake8.options.config' has no attribute 'ConfigFileFinder' ========================================================= 13 failed, 3 passed, 13 skipped, 29 warnings in 1.09s ========================================================== ERROR: InvocationError for command /home/partha/PycharmProjects/flask-api-tutorial-0.1/.tox/py310/bin/pytest (exited with code 1) ____ summary ____ ERROR: py310: commands failed

vikacisys commented 1 year ago

Solved the above error. In tox.ini, under deps =,

-    flake8
+    flake8 < 5.0.0
sub-Void commented 1 year ago

Awesome tutorial so far. Really enjoying the way it's organized and learning from your design decisions. Thanks. Also wanted to point out that keeping "werkzeug==0.16.1" is causing more problems than it's fixing at this point in time. The newer version is working for me.

huskarik commented 10 months ago

Hello! I can't run pip install -e .[dev], python version 3.11, There are many errors in the virtual environment files when running the command. I don't understand why, has anyone encountered this?

huskarik commented 10 months ago

Be like ERROR: Exception: Traceback (most recent call last): File "C:\WORK2\CreateApi\venv\Lib\site-packages\pip_internal\cli\base_command.py", line 180, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "C:\WORK2\CreateApi\venv\Lib\site-packages\pip_internal\cli\req_command.py", line 245, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\WORK2\CreateApi\venv\Lib\site-packages\pip_internal\commands\install.py", line 377, in run requirement_set = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "C:\WORK2\CreateApi\venv\Lib\site-packages\pip_internal\resolution\resolvelib\resolver.py", line 76, in resolve collected = self.factory.collect_root_requirements(root_reqs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

etc.

KarolNie1992 commented 3 months ago

Maybe this will be helpful, in order for all tests to be performed correctly, they should be changed in files

[testenv] deps = black==19.10b0 flake8==3.7.9 pydocstyle==5.0.2 pytest==5.3.5 pytest-black==0.3.8 pytest-clarity==0.3.0a0 pytest-dotenv==0.4.0 pytest-flake8==1.0.4 pytest-flask==0.15.1

commands = pytest


- setup.py

INSTALL_REQUIRES = [ "Click==7.0", "SQLAlchemy==1.3.13", "itsdangerous==1.1.0", "MarkupSafe==1.1.1", "Jinja2==2.11.1", "Flask==1.1.1", "Flask-Bcrypt==0.7.1", "Flask-Cors==3.0.8", "Flask-Migrate==2.5.2", "flask-restx==0.1.1", "Flask-SQLAlchemy==2.4.1", "PyJWT==1.7.1", "python-dateutil==2.8.1", "python-dotenv==0.11.0", "requests", "urllib3==1.25.8",

"werkzeug",

"werkzeug==0.16.1",

] EXTRAS_REQUIRE = { "dev": [ "black==19.10b0", "flake8==3.7.9", "pre-commit", "pydocstyle==5.0.2", "pytest==5.3.5", "pytest-black==0.3.8", "pytest-clarity==0.3.0a0", "pytest-dotenv==0.4.0", "pytest-flake8==1.0.4", "pytest-flask==0.15.1", "tox", ] }