Git Product home page Git Product logo

blogin's Issues

UnboundLocalError: local variable 'results' referenced before assignment

在logs/blogin.log我看老是出现下面的error.

nboundLocalError: local variable 'results' referenced before assignment
2022-05-05 06:21:18,797 - blogin - ERROR - Exception on /blog/article/15/ [GET]
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/pymysql/connections.py", line 571, in connect
**kwargs)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2338, in _wrap_pool_connect
return fn()
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 182, in raise

raise exception
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 182, in raise

raise exception
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/home/ubuntu/.local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/home/ubuntu/.local/lib/python3.6/site-packages/pymysql/init.py", line 94, in Connect
return Connection(*args, **kwargs)
File "/home/ubuntu/.local/lib/python3.6/site-packages/pymysql/connections.py", line 327, in init
self.connect()
File "/home/ubuntu/.local/lib/python3.6/site-packages/pymysql/connections.py", line 619, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")

The above exception was the direct cause of the following exception:

博客地址无法访问了

佬 很喜欢你的博客、但是今天发现你的博客地址访问不了了。佬千万不要放弃这个项目呀、佬。

部署到AWS ec2 ubuntu 上出现了问题

按照以前那种 使用nginx、gunicorn部署Flask项目]
504 Gateway Time-out
nginx/1.18.0 (Ubuntu)

2023/05/03 14:02:12 [error] 8246#8246: *17 upstream timed out (110: Unknown error) while reading response header from upstream, client: 133.200.176.xx,>

用户验证改造

你好
我发现我的数据库被恶意攻击啦,很多注册用户都是垃圾。
image

我的第一步改造就是用户需要在邮箱点击后才能算正式注册。
这一步怎么修改啊。还有加入防止机器人恶意注册。
能否指点一下咋修改

依赖的文件缺失

blogin/templates/backend/base.html第二行 {% extends "bootstrap/base.html" %}用到了bootstrap/base.html, 然而项目中并没有这个文件夹以及文件

初始化数据库命令失败

(venv) (base) zw@DESKTOP-TIVUPRV:~/code/Blogin$ flask initdb
Usage: flask [OPTIONS] COMMAND [ARGS]...
Try 'flask --help' for help.

Error: No such command 'initdb'.

Internal Server Error

你好, 网站出现了Internal Server Error,博客都无法展示 ,但是一般页面可以展示,但是博客内容以及其他的内容无法展示。这一般啥问题

我打算开发一个活动栏目。

我打算开发一个活动栏目。比如有啥足球活动,我想大家可以报名参加,有活动标题以及信息,活动内容,时间,地点,以及报名按钮。可有啥建议咋设计这个?如果有相关模版就好了。

在本地调试初始化数据库的时候报错

D:\Blogin>flask initdb
Error: While importing 'blogin', an ImportError was raised.

Usage: flask [OPTIONS] COMMAND [ARGS]...
Try 'flask --help' for help.

Error: No such command 'initdb'.
是循环导入了吗?

个人博客云端部署问题

大佬,为什么我把博客部署到腾讯云服务器(windows系统),输入flask run运行之后,我再本地访问不到页面啊
image
image

avatar文件路径的问题

AVATARS_SAVE_PATH = BLOGIN_UPLOAD_PATH + '/avatars/'

用户头像确实是保存在了根目录的 uploads/avatars/ 下面

但是在blog.user表中avatar的路径是 /accounts/avatar/

导致首页加载用户头像不成功。

No file blogin.log

  File "/Users/liam/Desktop/Git/Blogin/env/bin/flask", line 10, in <module>
    sys.exit(main())
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 967, in main
    cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 586, in main
    return super(FlaskGroup, self).main(*args, **kwargs)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/click/core.py", line 1254, in invoke
    cmd_name, cmd, args = self.resolve_command(ctx, args)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/click/core.py", line 1297, in resolve_command
    cmd = self.get_command(ctx, cmd_name)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 542, in get_command
    rv = info.load_app().cli.get_command(ctx, name)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 257, in locate_app
    return find_best_app(script_info, module)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 83, in find_best_app
    app = call_factory(script_info, app_factory)
  File "/Users/liam/Desktop/Git/Blogin/env/lib/python3.7/site-packages/flask/cli.py", line 119, in call_factory
    return app_factory()
  File "/Users/liam/Desktop/Git/Blogin/blogin/__init__.py", line 55, in create_app
    register_log(app)
  File "/Users/liam/Desktop/Git/Blogin/blogin/__init__.py", line 238, in register_log
    file_handler = RotatingFileHandler('logs/blogin.log', maxBytes=10 * 1024 * 1024, backupCount=10)
  File "/Users/liam/opt/anaconda3/lib/python3.7/logging/handlers.py", line 148, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/Users/liam/opt/anaconda3/lib/python3.7/logging/handlers.py", line 55, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/Users/liam/opt/anaconda3/lib/python3.7/logging/__init__.py", line 1087, in __init__
    StreamHandler.__init__(self, self._open())
  File "/Users/liam/opt/anaconda3/lib/python3.7/logging/__init__.py", line 1116, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/liam/Desktop/Git/Blogin/logs/blogin.log'

进首页显示404

请问我把博客部署到ubuntu系统的服务器后,进入首页显示404,但是其它页面正常显示是什么问题啊
image
image
image

添加.env文件后flask命令无法使用了

我在使用flask initdb的时候发现了下面的错误,经过查找,发现添加.env文件后flask命令无法使用了,就会报这个错误,请问能怎么解决吗?

(python38) D:\DATA\resume\Blogin-master>flask initdb
Traceback (most recent call last):
File "E:\ProgramData\Anaconda3\envs\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "E:\ProgramData\Anaconda3\envs\python38\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "E:\ProgramData\Anaconda3\envs\python38\Scripts\flask.exe_main
.py", line 7, in
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\flask\cli.py", line 967, in main
cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\flask\cli.py", line 575, in main
load_dotenv()
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\flask\cli.py", line 649, in load_dotenv
dotenv.load_dotenv(path)
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\main.py", line 312, in load_dotenv
return DotEnv(f, verbose=verbose, interpolate=interpolate, **kwargs).set_as_environment_variables(override=override)
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\main.py", line 102, in set_as_environment_variables
for k, v in self.dict().items():
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\main.py", line 86, in dict
values = OrderedDict(self.parse())
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\main.py", line 93, in parse
for mapping in with_warn_for_invalid_lines(parse_stream(stream)):
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\main.py", line 48, in with_warn_for_invalid_lines
for mapping in mappings:
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\parser.py", line 235, in parse_stream
reader = Reader(stream)
File "E:\ProgramData\Anaconda3\envs\python38\lib\site-packages\dotenv\parser.py", line 107, in init
self.string = stream.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 113: illegal multibyte sequence

AttributeError: 'NoneType' object has no attribute 'content'

我现在允许OK啦,但是老是出现这个问题,在运行terminal上。
rv = f(*args, **kwargs)
File "/Users/xx/PycharmProjects/Blogin/blogin/blueprint/front/blog.py", line 308, in load_one
return jsonify({'one': one.content})
AttributeError: 'NoneType' object has no attribute 'content'

configparser.NoSectionError: No section: 'baidu'

File "/Users/xx/PycharmProjects/Blogin/blogin/blueprint/front/blog.py", line 18, in
from blogin.utils import redirect_back, github_social, BOOTSTRAP_SUFFIX
File "/Users/xx/PycharmProjects/Blogin/blogin/utils.py", line 281, in
OCR_TOKEN = config_ini.get('baidu', 'token')
File "/opt/anaconda3/lib/python3.8/configparser.py", line 781, in get
d = self._unify_values(section, vars)
File "/opt/anaconda3/lib/python3.8/configparser.py", line 1149, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'baidu'

jinja2.exceptions.TemplateNotFound: main/index.html

我把根文件名改成scisci后,然后flask run 后是这个问题

jinja2.exceptions.TemplateNotFound: main/index.html

`File "/Users/xx/PycharmProjects/SciSci/scisci/blueprint/front/blog.py", line 45, in index
    plans = Plan.query.filter_by(is_done=0).all()
    su = User.query.filter(User.email == '[email protected]').first()
    flinks = FriendLink.query.filter(FriendLink.flag == 1).all()
    msg_borders = MessageBorder.query.filter(MessageBorder.flag == 0, MessageBorder.parent_id == 0
                                             ).order_by(MessageBorder.timestamps.desc()).all()[0:5]
    return render_template('main/index.html', per_page=current_app.config['BLOGIN_BLOG_PER_PAGE'],
                           pagination=pagination, blogs=blogs, cates=cates, categories=categories,
                           loves=loves, su=su, flinks=flinks, plans=plans, msg_borders=msg_borders)
 
 
@blog_bp.route('/themes/<string:theme_name>/')

我在local时候重新修改我写的博客,然后保存编辑的时候出现了:sqlalchemy.exc.OperationalError

sqlalchemy.exc.OperationalError
sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely)
(pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
[SQL: UPDATE blog SET content=%(content)s WHERE blog.id = %(blog_id)s]
[parameters: {'content': '

学习图像

\r\n\r\n

 

\r\n\r\n

xxx

\r\n', 'blog_id': 1}]
(Background on this error at: http://sqlalche.me/e/13/e3q8)

插入数据问题

我发现前台中每日一句板块中无法加载,研究了下源代码中发现根本未插入到数据库中,测试了下代码发现
Snipaste_2021-08-25_16-58-32

运行过程中出现以下错误

File "E:\OneDrive\桌面\2\Blogin\blogin\blueprint\front\oauth.py", line 38, in
authorize_url='https://gitee.com/oauth/authorize',
File "E:\flask\Blogin-lJF8C-Se\lib\site-packages\flask_oauthlib\client.py", line 78, in remote_app
remote = OAuthRemoteApp(self, name, **kwargs)
File "E:\flask\Blogin-lJF8C-Se\lib\site-packages\flask_oauthlib\client.py", line 285, in init
"OAuthRemoteApp requires consumer key and secret"
TypeError: OAuthRemoteApp requires consumer key and secret

数据库死锁

(pymysql.err.OperationalError) (1205, 'Lock wait timeout exceeded; try restarting transaction')
image

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.