小编And*_*ujo的帖子

使用承载令牌授权标头(flask_restful +flask_jwt_extended)发送 GET 消息时出现“段不足”

我在 Flask 应用程序中收到此错误:

curl http://0.0.0.0:8080/ -H "Authorization: Bearer TGazPL9rf3aIftplCYDTGDc8cbTd"
{
  "msg": "Not enough segments"
}
Run Code Online (Sandbox Code Playgroud)

这是一个示例:

from flask import Flask
from flask_restful import Resource, Api
from flask_jwt_extended import JWTManager, jwt_required

app = Flask(__name__)
jwt = JWTManager(app)
api = Api(app)


class HelloWorld(Resource):
    @jwt_required
    def get(self):
        return {'hello': 'world'}


api.add_resource(HelloWorld, '/')
Run Code Online (Sandbox Code Playgroud)

安慰:

 * Serving Flask app "app.py" (lazy loading)
 * Environment: development
 * Debug mode: on
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active! …
Run Code Online (Sandbox Code Playgroud)

flask flask-restful pyjwt flask-jwt-extended jwt-auth

6
推荐指数
1
解决办法
9704
查看次数

如何使用诗歌添加私人存储库?

使用Artifactory(https://cloud.google.com/artifact-registry)我打算添加对诗歌的依赖(https://python-poetry.org/docs/repositories/)。

我可以使用命令安装:(pip install --index-url https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/ <PACKAGE_NAME>使用 keyrings.google-artifactregistry-auth 进行身份验证)

我打算使用 POETRY 来管理我的依赖项。我不知道使用诗歌是否会增加这种依赖性。poetry add --source <PACKAGE_NAME> https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>我收到此错误:

poetry update
Updating dependencies
Resolving dependencies... (0.9s)

  RepositoryError

  401 Client Error: Unauthorized for url: https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/pytest/
Run Code Online (Sandbox Code Playgroud)

我的 pyproject.toml

...

[[tool.poetry.source]]
name = "SOME_LIB"
url = " https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/"
secondary = true
Run Code Online (Sandbox Code Playgroud)

这里有如何使用 PIP/VIRTUALENV 进行配置的详细信息:https://cloud.google.com/artifact-registry/docs/python/authentication但没有有关 Poetry 的详细信息。

您对此有什么建议吗?

python python-packaging python-poetry google-artifact-registry

6
推荐指数
1
解决办法
1090
查看次数

如何在 Sqlalchemy 中使用 automap_base 处理 AttributeError(key)?

请帮助如何解决此错误 - AttributeError(key):

  File "pivot_table_measurements.py", line 1, in <module>
    from database import *
  File "/home/dedeco/Projetos/bigclima-project/database.py", line 24, in <module>
    MeasureRanges = Base.classes.measure_ranges
  File "/home/dedeco/craw/lib/python3.5/site-packages/sqlalchemy/util/_collections.py", line 212, in __getattr__
    raise AttributeError(key)
AttributeError: measure_ranges
Run Code Online (Sandbox Code Playgroud)

数据库.py:

from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
import string
from decimal import Decimal

ECHO = False
AUTOFLUSH = False

Base = automap_base()

engine = create_engine('postgresql://user:pass@localhost:5432/clima', echo=ECHO)

Base.prepare(engine, reflect=True)

Country = Base.classes.countries
State = Base.classes.states
City = Base.classes.cities …
Run Code Online (Sandbox Code Playgroud)

python orm sqlalchemy

3
推荐指数
1
解决办法
3966
查看次数

如何从数组在excel中写入整行 - xlwt

我想改进我的代码,替换这个:

workbook = xlwt.Workbook()
sheet = workbook.add_sheet("WS") 

header = [u'Nome da estação',u'Altitude',u'Latitude',u'Longitude']

column =0
for h in header:
    sheet.write(0, column, h)
    column += 1
Run Code Online (Sandbox Code Playgroud)

对于某些代码直接使用数组头来写一整行。任何的想法?

python excel xlwt

2
推荐指数
1
解决办法
7334
查看次数

pip安装FuzzySet在OSX上失败 - virtualenv与python3

我正在尝试在我的virtualenv中安装FuzzySet:

(virtualenv) machine:user$ pip install FuzzySet
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误:

(virtualenv) machine:user$ pip install FuzzySet
Collecting FuzzySet
  Using cached fuzzyset-0.0.11.tar.gz
Requirement already satisfied: python-levenshtein in /Users/dedeco/Envs/Craw/lib/python3.6/site-packages (from FuzzySet)
Requirement already satisfied: texttable in /Users/dedeco/Envs/Craw/lib/python3.6/site-packages (from FuzzySet)
Requirement already satisfied: setuptools in /Users/dedeco/Envs/Craw/lib/python3.6/site-packages (from python-levenshtein->FuzzySet)
Building wheels for collected packages: FuzzySet
  Running setup.py bdist_wheel for FuzzySet ... error
  Complete output from command /Users/dedeco/Envs/Craw/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/y7/1vddc8q51zq_q_dc0gw581480000gn/T/pip-build-1e0boni3/FuzzySet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/y7/1vddc8q51zq_q_dc0gw581480000gn/T/tmpbguw98h6pip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_py …
Run Code Online (Sandbox Code Playgroud)

python macos pip python-3.x

2
推荐指数
2
解决办法
969
查看次数