Giter Club home page Giter Club logo

mini-shop-server's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mini-shop-server's Issues

raise BadRequest("Failed to decode JSON object: {0}".format(e))

req_body = request.get_json() if request.get_json() else {}
这里报错(我是在小程序端调用)
raise BadRequest("Failed to decode JSON object: {0}".format(e))
那行加了try···except···后log输出
"path": {}, "query": {}, "body": {}
可能是request没有获得参数?

sqlalchemy 字段中设置默认值为UrlFromEnum.LOCAL 不能正确create

UrlFromEnum.LOCAL 来自配置文件中设置的变量 来源: 1 本地,2 公网

from app.libs.enums import UrlFromEnum

class File(Base):
tablename = 'file'
id = Column(Integer, primary_key=True)
parent_id = Column(Integer, comment='父级目录id')
uuid_name = Column(String(100), comment='唯一名称')
name = Column(String(100), nullable=False, comment='原始名称')
path = Column(String(500), comment='路径')
extension = Column(String(50), comment='后缀')
_from = Column('from', SmallInteger, default=file_from, comment='来源: 1 本地,2 公网')

在上传文件接口

uploader = LocalUploader(files) # 或者导入,使用 QiniuUploader
uploader.locate(parent_id=id)
res = uploader.upload()

uploader方法中

File.create(
parent_id=self.parent_id,
name=single.filename,
uuid_name=uuid_filename,
path=relative_path,
extension=self._get_ext(single.filename),
size=self._get_size(single),
md5=file_md5
)

失败,报错

image

错误日志如下:

127.0.0.1 - - [02/Mar/2021 11:57:34] "POST /cms/file/1 HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 2464, in call
return self.wsgi_app(environ, start_response)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\werkzeug\middleware\proxy_fix.py", line 169, in call
return self.app(environ, start_response)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask_cors\extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask_compat.py", line 39, in reraise
raise value
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask_cors\extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 1822, in handle_user_exception
return handler(e)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\app_init_.py", line 128, in framework_error
raise e
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\flasgger\utils.py", line 248, in wrapper
return function(*args, **kwargs)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\app\extensions\api_docs\redprint.py", line 59, in wrapper
return f(*args, **kwargs)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\app\api\cms\file.py", line 46, in upload_file
res = uploader.upload()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\app\extensions\file\local_uploader.py", line 49, in upload
md5=file_md5
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\app\core\db.py", line 162, in create
return instance.save(commit)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\app\core\db.py", line 176, in save
db.session.commit()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\scoping.py", line 163, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\session.py", line 1042, in commit
self.transaction.commit()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\session.py", line 504, in commit
self._prepare_impl()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\session.py", line 483, in _prepare_impl
self.session.flush()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\session.py", line 2536, in flush
self._flush(objects)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\session.py", line 2678, in _flush
transaction.rollback(capture_exception=True)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\util\langhelpers.py", line 70, in exit
with_traceback=exc_tb,
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\util\compat.py", line 182, in raise

raise exception
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\session.py", line 2638, in _flush
flush_context.execute()
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 422, in execute
rec.execute(self)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 589, in execute
uow,
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\persistence.py", line 245, in save_obj
insert,
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\orm\persistence.py", line 1136, in _emit_insert_statements
statement, params
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\engine\base.py", line 1011, in execute
return meth(self, multiparams, params)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\sql\elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\engine\base.py", line 1130, in _execute_clauseelement
distilled_params,
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\engine\base.py", line 1317, in execute_context
e, statement, parameters, cursor, context
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\engine\base.py", line 1514, in handle_dbapi_exception
util.raise
(exc_info[1], with_traceback=exc_info[2])
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\util\compat.py", line 182, in raise

raise exception
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\engine\base.py", line 1277, in _execute_context
cursor, statement, parameters, context
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\sqlalchemy\engine\default.py", line 593, in do_execute
cursor.execute(statement, parameters)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\cymysql\cursors.py", line 117, in execute
escaped_args = tuple(conn.escape(arg) for arg in args)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\cymysql\cursors.py", line 117, in
escaped_args = tuple(conn.escape(arg) for arg in args)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\cymysql\connections.py", line 306, in escape
return escape_item(obj, self.charset, self.encoders)
File "C:\Users\57137\Desktop\微信小程序\小程序后端\mini-shop-server-dev\f-venv\lib\site-packages\cymysql\converters.py", line 327, in escape_item
return encoderstype(val)
KeyError: <enum 'UrlFromEnum'>

web端网页验证的问题

我使用了mini-shop-server的后端,管理前端用的是lin-cms-vue-0.2.x,
遇到的问题是,登录后,获取需要权限的数据(@auth.login_required)提示“UNAUTHORIZED”,
我按照小程序里的格式添加了请求头也是无效的。
有什么解决方法吗?
axios.js:

        var header = {
          'content-type': 'application/json',
          'authorization': `Basic ${Base64.encode(`${accessToken}:$`)}`
        }
        reqConfig.headers = header

另外,请教一下,小程序请求头中为什么要base64encode呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.