flask响应return时老是报相同的错:TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

flask响应return时老是报相同的错:TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

python代码为:

在这里插入图片描述

html代码:

在这里插入图片描述

奇怪的是另一个与这样相同的响应可以成功跳转,但只有这个不行……
求助!!!

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
使用flask的request对象的method属性报错
刚学flask写了个简单的demo #-*- encoding = UTF-8 -*- from flask import Flask,render_template,request import request app = Flask(__name__) @app.route('/login/',methods=['POST', 'GET']) def login(): if request.method == 'POST': if request.form['user'] == 'admin': return 'Admin login successfully!' else: return 'No such user!' title = request.args.get('title', 'Default') return render_template('login.html', title=title) if __name__ == '__main__': app.run(debug=True) 结果报错AttributeError AttributeError: 'module' object has no attribute 'method'
python flask在主app.py文件中定义了一个工厂函数create_app(),并且创建列一个app实例,为什么还是会报Failed to find application in module "app"的错误。
python flask在主app.py文件中定义了一个工厂函数create_app(),并且创建列一个app实例,为什么还是会报Failed to find application in module "app"的错误。 工厂函数以及main方法 ``` # --app.py def create_app(): app = Flask(__name__) app.config.from_object(config) return app if __name__ == '__main__': app = create_app() app.run() ``` 为什么还是报错: Error: Failed to find application in module "app". Are you sure it contains a Flask application? Maybe you wrapped it in a WSGI middleware or you are using a factory function.
flask教程数据库部分报错
http://www.pythondoc.com/flask-mega-tutorial/database.html#id2 按照这个教程上db_migrate.py的代码 运行之后报错 Traceback (most recent call last): File "./db_migrate.py", line 11, in <module> script = api.make_update_script_for_model(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO, tmp_module.meta, db.metadata) AttributeError: 'module' object has no attribute 'meta'
flask web教程 第十一章,添加博客文章 报错UndefinedError: 'Permission' is undefined
我根据github源码来的怎么还出错了,已经更新了数据库。访问首页就报错了 Traceback (most recent call last) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1997, in __call__ return self.wsgi_app(environ, start_response) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1985, in wsgi_app response = self.handle_exception(e) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1540, in handle_exception reraise(exc_type, exc_value, tb) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "E:\zt_6.27\pictureme\app\main\views.py", line 20, in index return render_template('index.html', form=form, posts=posts) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\templating.py", line 134, in render_template context, ctx.app) File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask\templating.py", line 116, in _render rv = template.render(context) File "E:\zt_6.27\pictureme\flask\lib\site-packages\jinja2\environment.py", line 1008, in render return self.environment.handle_exception(exc_info, True) File "E:\zt_6.27\pictureme\flask\lib\site-packages\jinja2\environment.py", line 780, in handle_exception reraise(exc_type, exc_value, tb) File "E:\zt_6.27\pictureme\flask\lib\site-packages\jinja2\_compat.py", line 37, in reraise raise value.with_traceback(tb) File "E:\zt_6.27\pictureme\app\templates\index.html", line 2, in top-level template code {% import "bootstrap/wtf.html" as wtf %} File "E:\zt_6.27\pictureme\app\templates\base.html", line 1, in top-level template code {% extends "bootstrap/base.html" %} File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask_bootstrap\templates\bootstrap\base.html", line 1, in top-level template code {% block doc -%} File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask_bootstrap\templates\bootstrap\base.html", line 4, in block "doc" {%- block html %} File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask_bootstrap\templates\bootstrap\base.html", line 20, in block "html" {% block body -%} File "E:\zt_6.27\pictureme\flask\lib\site-packages\flask_bootstrap\templates\bootstrap\base.html", line 23, in block "body" {% block content -%} File "E:\zt_6.27\pictureme\app\templates\base.html", line 58, in block "content" {% block page_content %}{% endblock %} File "E:\zt_6.27\pictureme\app\templates\index.html", line 11, in block "page_content" {% if current_user.can(Permission.WRITE) %} File "E:\zt_6.27\pictureme\flask\lib\site-packages\jinja2\environment.py", line 430, in getattr return getattr(obj, attribute) jinja2.exceptions.UndefinedError: 'Permission' is undefined 求大神解答一下!!!!
flask session.clear() 清除后,第二次请求过来又带上了?
现在做的是登陆校验,会把一些敏感信息写session,session放在cookie里,,现在前端点击退出后,后台会清除session 后台的退出视图:主要就是清session信息 session.clear() return {"code":200} 断点到这个return,查看session清除情况 session是空的 但第二次同一条请求过来 又带上了原来写在session里面的数据 这是怎么回事?? 难道 session.clear() 只是清除服务端的? 浏览器本地cookie里的session 必须 要构造响应头后,del_cookie("session") 后 返回给前端 才能清除??? 这有点不合理啊
flask中响应的http协议版本问题
是个新人菜鸟,刚开始用flask,发现发送的请求采用的是http1.1,但返回的响应却是http1.0的,请问怎么才能把http1.0改为1.1版本?
部署flask项目到heroku上时,出现psycopg2.errors.UndefinedTable: relation "question" does not exist问题,该怎么解决?
当我把flask项目部署到heroku上后,打开app时显示**Internal Server Error**. 报错为 ``` psycopg2.errors.UndefinedTable: relation "question" does not exist ``` 我google下,可能是由于migrations文件导致的,于是我就把该文件删掉了。但依然出现同样的问题。 求大神帮忙,现在踩在坑里有点出不去了。 这是我的config.py文件: ``` import os DEBUG = True SECRET_KEY = os.urandom(24) MAX_CONTENT_LENGTH = 1 * 1024 * 1024 SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') SQLALCHEMY_TRACK_MODIFICATIONS=False ``` 下面是heroku 的logs: ``` 2019-11-17T08:43:29.637889+00:00 app[web.1]: [2019-11-17 08:43:29 +0000] [11] [ERROR] Error handling request / 2019-11-17T08:43:29.637935+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:43:29.637940+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:43:29.637942+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:43:29.637945+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:43:29.637947+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:43:29.637949+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T08:43:29.637952+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:43:29.637955+00:00 app[web.1]: ^ 2019-11-17T08:43:29.637956+00:00 app[web.1]: 2019-11-17T08:43:29.637958+00:00 app[web.1]: 2019-11-17T08:43:29.637960+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T08:43:29.637962+00:00 app[web.1]: 2019-11-17T08:43:29.637964+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:43:29.637966+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T08:43:29.637968+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T08:43:29.637970+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T08:43:29.637972+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T08:43:29.637984+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T08:43:29.637986+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T08:43:29.637988+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T08:43:29.637990+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T08:43:29.637992+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T08:43:29.637993+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:43:29.637995+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:43:29.637997+00:00 app[web.1]: raise value 2019-11-17T08:43:29.637999+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T08:43:29.638000+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T08:43:29.638002+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T08:43:29.638004+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T08:43:29.638006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T08:43:29.638008+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:43:29.638010+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:43:29.638011+00:00 app[web.1]: raise value 2019-11-17T08:43:29.638013+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T08:43:29.638015+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T08:43:29.638017+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T08:43:29.638019+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T08:43:29.638021+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T08:43:29.638023+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T08:43:29.638025+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T08:43:29.638027+00:00 app[web.1]: return list(self) 2019-11-17T08:43:29.638029+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T08:43:29.638031+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T08:43:29.638033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T08:43:29.638035+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T08:43:29.638037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T08:43:29.638039+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T08:43:29.638041+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T08:43:29.638043+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T08:43:29.638045+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T08:43:29.638047+00:00 app[web.1]: distilled_params, 2019-11-17T08:43:29.638049+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T08:43:29.638051+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T08:43:29.638053+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T08:43:29.638055+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T08:43:29.638057+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T08:43:29.638059+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T08:43:29.638061+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T08:43:29.638063+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T08:43:29.638076+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:43:29.638079+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:43:29.638081+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:43:29.638083+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:43:29.638085+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T08:43:29.638087+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:43:29.638089+00:00 app[web.1]: ^ 2019-11-17T08:43:29.638091+00:00 app[web.1]: 2019-11-17T08:43:29.638095+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T08:43:29.638097+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] 2019-11-17T08:43:29.638099+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405) 2019-11-17T08:43:29.638285+00:00 app[web.1]: 10.61.164.89 - - [17/Nov/2019:08:43:29 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2019-11-17T08:44:42.918911+00:00 app[web.1]: [2019-11-17 08:44:42 +0000] [11] [ERROR] Error handling request / 2019-11-17T08:44:42.918940+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:44:42.918944+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:44:42.918946+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:44:42.918948+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:44:42.918950+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:44:42.918952+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T08:44:42.918955+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:44:42.918957+00:00 app[web.1]: ^ 2019-11-17T08:44:42.918959+00:00 app[web.1]: 2019-11-17T08:44:42.918961+00:00 app[web.1]: 2019-11-17T08:44:42.918963+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T08:44:42.918965+00:00 app[web.1]: 2019-11-17T08:44:42.918967+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:44:42.918969+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T08:44:42.918971+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T08:44:42.918973+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T08:44:42.918975+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T08:44:42.918977+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T08:44:42.918979+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T08:44:42.918981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T08:44:42.918983+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T08:44:42.918985+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T08:44:42.918988+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:44:42.918989+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:44:42.918991+00:00 app[web.1]: raise value 2019-11-17T08:44:42.918994+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T08:44:42.918996+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T08:44:42.918998+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T08:44:42.919000+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T08:44:42.919002+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T08:44:42.919004+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:44:42.919006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:44:42.919008+00:00 app[web.1]: raise value 2019-11-17T08:44:42.919010+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T08:44:42.919012+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T08:44:42.919014+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T08:44:42.919016+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T08:44:42.919018+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T08:44:42.919020+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T08:44:42.919022+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T08:44:42.919025+00:00 app[web.1]: return list(self) 2019-11-17T08:44:42.919027+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T08:44:42.919028+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T08:44:42.919031+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T08:44:42.919033+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T08:44:42.919035+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T08:44:42.919037+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T08:44:42.919039+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T08:44:42.919041+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T08:44:42.919043+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T08:44:42.919046+00:00 app[web.1]: distilled_params, 2019-11-17T08:44:42.919048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T08:44:42.919050+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T08:44:42.919052+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T08:44:42.919054+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T08:44:42.919056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T08:44:42.919058+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T08:44:42.919060+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T08:44:42.919063+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T08:44:42.919074+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:44:42.919077+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:44:42.919079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:44:42.919081+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:44:42.919083+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T08:44:42.919085+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:44:42.919087+00:00 app[web.1]: ^ 2019-11-17T08:44:42.919088+00:00 app[web.1]: 2019-11-17T08:44:42.919091+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T08:44:42.919094+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] 2019-11-17T08:44:42.919096+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405) 2019-11-17T08:44:42.919234+00:00 app[web.1]: 10.5.225.117 - - [17/Nov/2019:08:44:42 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2019-11-17T08:44:42.918749+00:00 heroku[router]: at=info method=GET path="/" host=tianliang-flask-app.herokuapp.com request_id=c195162e-6529-4fb0-9aac-1d9dd9a450e8 fwd="58.182.174.147" dyno=web.1 connect=1ms service=7ms status=500 bytes=244 protocol=https 2019-11-17T09:02:25.748890+00:00 app[web.1]: [2019-11-17 09:02:25 +0000] [12] [ERROR] Error handling request / 2019-11-17T09:02:25.748917+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:02:25.748921+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:02:25.748923+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:02:25.748932+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:02:25.748934+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:02:25.748936+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T09:02:25.748939+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:02:25.748943+00:00 app[web.1]: ^ 2019-11-17T09:02:25.748944+00:00 app[web.1]: 2019-11-17T09:02:25.748947+00:00 app[web.1]: 2019-11-17T09:02:25.748949+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T09:02:25.748950+00:00 app[web.1]: 2019-11-17T09:02:25.748952+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:02:25.748953+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T09:02:25.748955+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T09:02:25.748956+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T09:02:25.748958+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T09:02:25.748991+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T09:02:25.748994+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T09:02:25.748996+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T09:02:25.748998+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T09:02:25.749000+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T09:02:25.749002+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:02:25.749004+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:02:25.749006+00:00 app[web.1]: raise value 2019-11-17T09:02:25.749008+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T09:02:25.749010+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T09:02:25.749012+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T09:02:25.749014+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T09:02:25.749016+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T09:02:25.749018+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:02:25.749020+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:02:25.749023+00:00 app[web.1]: raise value 2019-11-17T09:02:25.749024+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T09:02:25.749026+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T09:02:25.749027+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T09:02:25.749029+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T09:02:25.749030+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T09:02:25.749032+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T09:02:25.749033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T09:02:25.749036+00:00 app[web.1]: return list(self) 2019-11-17T09:02:25.749038+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T09:02:25.749039+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T09:02:25.749041+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T09:02:25.749042+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T09:02:25.749044+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T09:02:25.749045+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T09:02:25.749047+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T09:02:25.749048+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T09:02:25.749050+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T09:02:25.749051+00:00 app[web.1]: distilled_params, 2019-11-17T09:02:25.749053+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T09:02:25.749054+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T09:02:25.749056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T09:02:25.749057+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T09:02:25.749059+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T09:02:25.749060+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T09:02:25.749062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T09:02:25.749063+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T09:02:25.749074+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:02:25.749076+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:02:25.749078+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:02:25.749080+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:02:25.749082+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T09:02:25.749084+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:02:25.749087+00:00 app[web.1]: ^ 2019-11-17T09:02:25.749089+00:00 app[web.1]: 2019-11-17T09:02:25.749092+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T09:02:25.749094+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] 2019-11-17T09:02:25.749096+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405) 2019-11-17T09:02:25.749271+00:00 app[web.1]: 10.69.244.94 - - [17/Nov/2019:09:02:25 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2019-11-17T09:02:25.755053+00:00 heroku[router]: at=info method=GET path="/" host=tianliang-flask-app.herokuapp.com request_id=181975e4-7c78-4f7f-b131-4b1ddb544e02 fwd="58.182.174.147" dyno=web.1 connect=0ms service=92ms status=500 bytes=244 protocol=https 2019-11-17T09:06:00.663577+00:00 heroku[router]: at=info method=GET path="/" host=tianliang-flask-app.herokuapp.com request_id=571550f7-554b-42d0-b127-0a4837f6aae9 fwd="58.182.174.147" dyno=web.1 connect=1ms service=17ms status=500 bytes=244 protocol=https 2019-11-17T09:06:00.661593+00:00 app[web.1]: [2019-11-17 09:06:00 +0000] [11] [ERROR] Error handling request / 2019-11-17T09:06:00.661619+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:06:00.662439+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:06:00.662443+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:06:00.662447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:06:00.662449+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:06:00.662452+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T09:06:00.662455+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:06:00.662457+00:00 app[web.1]: ^ 2019-11-17T09:06:00.662459+00:00 app[web.1]: 2019-11-17T09:06:00.662461+00:00 app[web.1]: 2019-11-17T09:06:00.662464+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T09:06:00.662466+00:00 app[web.1]: 2019-11-17T09:06:00.662471+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:06:00.662473+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T09:06:00.662476+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T09:06:00.662478+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T09:06:00.662480+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T09:06:00.662483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T09:06:00.662486+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T09:06:00.662488+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T09:06:00.662491+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T09:06:00.662493+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T09:06:00.662495+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:06:00.662498+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:06:00.662500+00:00 app[web.1]: raise value 2019-11-17T09:06:00.662502+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T09:06:00.662505+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T09:06:00.662507+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T09:06:00.662509+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T09:06:00.662511+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T09:06:00.662513+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:06:00.662515+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:06:00.662517+00:00 app[web.1]: raise value 2019-11-17T09:06:00.662519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T09:06:00.662521+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T09:06:00.662523+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T09:06:00.662526+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T09:06:00.662528+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T09:06:00.662530+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T09:06:00.662532+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T09:06:00.662535+00:00 app[web.1]: return list(self) 2019-11-17T09:06:00.662537+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T09:06:00.662539+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T09:06:00.662541+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T09:06:00.662544+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T09:06:00.662546+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T09:06:00.662548+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T09:06:00.662550+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T09:06:00.662552+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T09:06:00.662555+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T09:06:00.662557+00:00 app[web.1]: distilled_params, 2019-11-17T09:06:00.662559+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T09:06:00.662562+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T09:06:00.662564+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T09:06:00.662566+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T09:06:00.662568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T09:06:00.662570+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T09:06:00.662573+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T09:06:00.662575+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T09:06:00.662587+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:06:00.662590+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:06:00.662592+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:06:00.662594+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:06:00.662596+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T09:06:00.662599+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:06:00.662601+00:00 app[web.1]: ^ 2019-11-17T09:06:00.662603+00:00 app[web.1]: 2019-11-17T09:06:00.662607+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T09:06:00.662609+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] ```
flask中HelloWorld都无法运行,这需要怎么解决?
**flask中HelloWorld都无法运行** ![图片说明](https://img-ask.csdn.net/upload/202002/21/1582294135_13903.png)![图片说明](https://img-ask.csdn.net/upload/202002/21/1582294142_794044.png)![图片说明](https://img-ask.csdn.net/upload/202002/21/1582294149_398549.png)![图片说明](https://img-ask.csdn.net/upload/202002/21/1582294158_166342.png)![图片说明](https://img-ask.csdn.net/upload/202002/22/1582341959_246573.png) ``` **源码** from flask import Flask app = Flask(__name__) @app.route('/') def hello_world()->str: return 'Hello World!' if __name__ == '__main__': app.run() ``` **报错信息** FLASK_APP = app.py FLASK_ENV = development FLASK_DEBUG = 0 In folder D:/pycharm项目/222 D:\pycharm项目\222\venv\Scripts\python.exe -m flask run * Serving Flask app "app.py" * Environment: development * Debug mode: off Traceback (most recent call last): File "C:\Users\78518\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\78518\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "D:\pycharm项目\222\venv\lib\site-packages\flask\__main__.py", line 15, in <module> main(as_module=True) File "D:\pycharm项目\222\venv\lib\site-packages\flask\cli.py", line 966, in main cli.main(prog_name="python -m flask" if as_module else None) File "D:\pycharm项目\222\venv\lib\site-packages\flask\cli.py", line 586, in main return super(FlaskGroup, self).main(*args, **kwargs) File "D:\pycharm项目\222\venv\lib\site-packages\click\core.py", line 717, in main rv = self.invoke(ctx) File "D:\pycharm项目\222\venv\lib\site-packages\click\core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "D:\pycharm项目\222\venv\lib\site-packages\click\core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "D:\pycharm项目\222\venv\lib\site-packages\click\core.py", line 555, in invoke return callback(*args, **kwargs) File "D:\pycharm项目\222\venv\lib\site-packages\click\decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args, **kwargs) File "D:\pycharm项目\222\venv\lib\site-packages\click\core.py", line 555, in invoke return callback(*args, **kwargs) File "D:\pycharm项目\222\venv\lib\site-packages\flask\cli.py", line 852, in run_command run_simple( File "D:\pycharm项目\222\venv\lib\site-packages\werkzeug\serving.py", line 1052, in run_simple inner() File "D:\pycharm项目\222\venv\lib\site-packages\werkzeug\serving.py", line 996, in inner srv = make_server( File "D:\pycharm项目\222\venv\lib\site-packages\werkzeug\serving.py", line 847, in make_server return ThreadedWSGIServer( File "D:\pycharm项目\222\venv\lib\site-packages\werkzeug\serving.py", line 740, in __init__ HTTPServer.__init__(self, server_address, handler) File "C:\Users\78518\AppData\Local\Programs\Python\Python38-32\lib\socketserver.py", line 452, in __init__ self.server_bind() File "C:\Users\78518\AppData\Local\Programs\Python\Python38-32\lib\http\server.py", line 139, in server_bind self.server_name = socket.getfqdn(host) File "C:\Users\78518\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 756, in getfqdn hostname, aliases, ipaddrs = gethostbyaddr(name) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 0: invalid continuation byte 进程已结束,退出代码1 ``` **求大神解决,这究竟怎么回事,需要怎么解决** ```
微信小程序和本地uploadFile报错
在这里的res无法得到正常的消息 ``` success:res=>{ wx.uploadFile({ url: 'http://127.0.0.1:5000/', filePath: res.tempFilePath, name: 'file', success: function (res) { var data = res.data console.log(data+"DDDDDD") console.log('上传成功...') } ``` 报的错误![图片说明](https://img-ask.csdn.net/upload/202003/27/1585312546_719156.png) 因为是做设计 所以没有买服务器和证书,我勾选了不检查域名了。而且flask端可以正确接收到图片,也可以进行正常操作。就是这最后一步无法实现,求大神帮助!
vuejs和flask的文件夹设置问题
各位高手,我在使用vuecli3和flask开发,我在目前开发的时候遇到用户头像图片该怎么放置的问题,详细如下: 1.我目前是vuecli3和flask单独运行,中间只用axios做一些数据交互。那我的用户头像图片是该放在vue目录下还是放在flask目录下? 2.如果放在flask目录下,那我在vue中该怎么写路径? 3.我目前开发是在vuecli3下写的代码,我build之后生成的文件该放在哪里? 4.综上问题,各位高手能不能给我一个vuecli3和flask的目录放置demo。
微信公众号验证出现TypeError: '<' not supported between instances of 'NoneType' and 'str'怎么解决。
python flask 开发微信公众号出现的问题 将字符串token 和获取的timestamp nonce 放入list1 sort()一下出现错误 ![图片说明](https://img-ask.csdn.net/upload/202003/19/1584628106_267821.png)
Flask-Whooshee的使用问题?
今天使用Flask-Whooshee进行检索,发现一个问题,在检索结果为一个字符时,它的检索结果为空!!! 例如: Photo.query.whooshee_search(q).paginate(page, per_page) 这里输入的q为“我”,待检索数据有两个“我”和“我是”,而它只会显示一个结果“我是”。 如果输入的q为“我”,待检索数据只有一个“我”,那它显示为空。 what?在线请教大佬们
python flask 网页报错
# 如图,我在python flask写的网页点击提交按钮后显示如图错误![点击提交按钮后显示如图](https://img-ask.csdn.net/upload/201612/23/1482426458_206238.png) # 查找错误,指向118行,![图片说明](https://img-ask.csdn.net/upload/201612/23/1482426537_664832.png) 前往118行,![图片说明](https://img-ask.csdn.net/upload/201612/23/1482426572_535955.png) 其中,c2是我用pymongo获取的mongodb的一个collection, c2里有{'name':'string'}按键值对。理说temp是一个字典,对于字典用temp['name']获取字典指定'name'键的值应该没错,为何说无法游标?而且这个程序在我关机之前可以运行,关机重启之后就报错。
python导入包时报TypeError错误
在使用python flask框架时,在导入自定义的一个python包时报错。具体说明见下: 在`responses.py`文件中编写`from flask import Flask`后导入自定义包时`from manager.tools import GlobalMap as Gl`报如下图片中错误 ![报TypeError](https://img-ask.csdn.net/upload/201803/24/1521898595_366178.png) 整个项目路径如下![图片说明](https://img-ask.csdn.net/upload/201803/24/1521899217_640824.png) 已知导入Flask后导入其他目录的自定义包(比如etc下的py文件)时不会报错,只有在导入manager目录下的py文件时会出错 。 `responses.py`包引入格式如下: ![responses](https://img-ask.csdn.net/upload/201803/24/1521898903_335963.png) 求解答。
全栈任务:用vuejs和flask写一个下载的组件
各位高手,我有一个比较特别的需求, 我在页面中有个a标签的文件名,用v-model绑定了一个文件id号,链接,点击后下载对应文件(我对应的文件都是以id号命名的) 本人纯业余学习vuejs+flask,只想完成一个公益网站,这个网站对社会很有意义,我之前只会增删改查,遇到这种文件上传下载就纯懵逼,我查了网站很多资料,都没有特别匹配我flask和vuejs。 希望各位多帮忙,帮我写个demo,代码能简单就简单,难的话我也看不懂,希望加注释,包括你大概的思路,用了哪些模块或者组件。 我的微信是15205166002,可以加微信交流在线指导。
Flask启动报未安装flask的错pycharm中debug模式可以启动怎么解决?
在Pycharm中用debug模式配置一下就可以启动但是我要用命令行中启动怎么操作呢? 我在命令行中用Python3 app.py 启动报未安装flask的错 环境都没问题 pycharm中可以直接跑
docker宿主机无法访问容器内启动的python服务问题
我的宿主机是CentOS7,安装的docker版本是19.03.8。我拉取了一个Ubuntu基础镜像,然后基于此创建了自己的python镜像,命名为"my-image"。 生成容器是的命令是: ``` docker run -it -p 50001:5000 my-image /bin/bash ``` 进入容器内部后,编写了如下一个python脚本: ``` # test.py from flask import Flask app = Flask(__name__) @app.route('/') def func(): return "Hello docker!" if __name__ == '__main__': app.run('0.0.0.0', port=5000) ``` 然后执行了"python test.py"启动了该服务,随后将容器挂起在后端运行。 在宿主机执行了以下命令请求该服务: ``` curl http://127.0.0.1:50001/ ``` 未成功,返回的结果是“curl: (56) Recv failure: Connection reset by peer” 请问有哪位大神知道问题出在哪里了吗?求不吝赐教。 > ps. “docker run”命令在默认情况下的网络连接模式是“bridge”,如果在执行“docker run”时指定为“host”: ``` docker run -it --network host ... ``` 那么就没有上述问题,而且直接访问容器的端口即可请求到该服务。
ProgrammingError: (pyodbc.ProgrammingError) ('42000', u"[42000] [FreeTDS][SQL Server]Some character(s) could not be converted into client's character set
python程序flask应用,docker部署, 数据库中有法语, 查询的时候报这上错,当然在window下面没问题, 在linux下才有这个问题,程序中用的sqlalchemy. 在linux环境下找到了odbcinst.ini文件, 但是这个文件里什么也没有,我也没有找到FreeTds的东西 File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 1131, in fetchall l = self.process_rows(self._fetchall_impl()) File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/result.py", line 1082, in _fetchall_impl return self.cursor.fetchall() ProgrammingError: (pyodbc.ProgrammingError) ('42000', u"[42000] [FreeTDS][SQL Server]Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?') (2403) (SQLGetData)") (Background on this error at: http://sqlalche.me/e/f405) 数据库中那个字段的法语值是这样的: TÉLÉCOMMUNI linux不熟, 请遇到过的大神们帮忙给看看,多谢啊
Python 运用pip install Flask-MySQLdb报错
如图所示,Python 运用pip install Flask-MySQLdb报错,本人已安装了Microsoft Visual C++ Compiler Package for Python 2.7![图片说明](https://img-ask.csdn.net/upload/201710/24/1508813254_220461.png)![图片说明](https://img-ask.csdn.net/upload/201710/24/1508813323_513292.png)
在中国程序员是青春饭吗?
今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...
【JSON解析】浅谈JSONObject的使用
简介 在程序开发过程中,在参数传递,函数返回值等方面,越来越多的使用JSON。JSON(JavaScript Object Notation)是一种轻量级的数据交换格式,同时也易于机器解析和生成、易于理解、阅读和撰写,而且Json采用完全独立于语言的文本格式,这使得Json成为理想的数据交换语言。 JSON建构于两种结构: “名称/值”对的集合(A Collection of name/va...
《MySQL 性能优化》之理解 MySQL 体系结构
本文介绍 MySQL 的体系结构,包括物理结构、逻辑结构以及插件式存储引擎。
程序员请照顾好自己,周末病魔差点一套带走我。
程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。
一名大专同学的四个问题
【前言】   收到一封来信,赶上各种事情拖了几日,利用今天要放下工作的时机,做个回复。   2020年到了,就以这一封信,作为开年标志吧。 【正文】   您好,我是一名现在有很多困惑的大二学生。有一些问题想要向您请教。   先说一下我的基本情况,高考失利,不想复读,来到广州一所大专读计算机应用技术专业。学校是偏艺术类的,计算机专业没有实验室更不用说工作室了。而且学校的学风也不好。但我很想在计算机领...
复习一周,京东+百度一面,不小心都拿了Offer
京东和百度一面都问了啥,面试官百般刁难,可惜我全会。
Java 14 都快来了,为什么还有这么多人固守Java 8?
从Java 9开始,Java版本的发布就让人眼花缭乱了。每隔6个月,都会冒出一个新版本出来,Java 10 , Java 11, Java 12, Java 13, 到2020年3月份,...
达摩院十大科技趋势发布:2020 非同小可!
【CSDN编者按】1月2日,阿里巴巴发布《达摩院2020十大科技趋势》,十大科技趋势分别是:人工智能从感知智能向认知智能演进;计算存储一体化突破AI算力瓶颈;工业互联网的超融合;机器间大规模协作成为可能;模块化降低芯片设计门槛;规模化生产级区块链应用将走入大众;量子计算进入攻坚期;新材料推动半导体器件革新;保护数据隐私的AI技术将加速落地;云成为IT技术创新的中心 。 新的画卷,正在徐徐展开。...
轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行用户代码,而用户只需根据实际代码运行所消耗的资源进行付费。Fun: Fun 是一个用于支持 Serverless 应用部署的工具,能帮助您便捷地管理函数计算、API ...
讲真,这两个IDE插件,可以让你写出质量杠杠的代码
周末躺在床上看《拯救大兵瑞恩》 周末在闲逛的时候,发现了两个优秀的 IDE 插件,据说可以提高代码的质量,我就安装了一下,试了试以后发现,确实很不错,就推荐给大家。 01、Alibaba Java 代码规范插件 《阿里巴巴 Java 开发手册》,相信大家都不会感到陌生,其 IDEA 插件的下载次数据说达到了 80 万次,我今天又贡献了一次。嘿嘿。 该项目的插件地址: https://github....
Python+OpenCV实时图像处理
目录 1、导入库文件 2、设计GUI 3、调用摄像头 4、实时图像处理 4.1、阈值二值化 4.2、边缘检测 4.3、轮廓检测 4.4、高斯滤波 4.5、色彩转换 4.6、调节对比度 5、退出系统 初学OpenCV图像处理的小伙伴肯定对什么高斯函数、滤波处理、阈值二值化等特性非常头疼,这里给各位分享一个小项目,可通过摄像头实时动态查看各类图像处理的特点,也可对各位调参、测试...
2020年一线城市程序员工资大调查
人才需求 一线城市共发布岗位38115个,招聘120827人。 其中 beijing 22805 guangzhou 25081 shanghai 39614 shenzhen 33327 工资分布 2020年中国一线城市程序员的平均工资为16285元,工资中位数为14583元,其中95%的人的工资位于5000到20000元之间。 和往年数据比较: yea...
为什么猝死的都是程序员,基本上不见产品经理猝死呢?
相信大家时不时听到程序员猝死的消息,但是基本上听不到产品经理猝死的消息,这是为什么呢? 我们先百度搜一下:程序员猝死,出现将近700多万条搜索结果: 搜索一下:产品经理猝死,只有400万条的搜索结果,从搜索结果数量上来看,程序员猝死的搜索结果就比产品经理猝死的搜索结果高了一倍,而且从下图可以看到,首页里面的五条搜索结果,其实只有两条才是符合条件。 所以程序员猝死的概率真的比产品经理大,并不是错...
害怕面试被问HashMap?这一篇就搞定了!
声明:本文以jdk1.8为主! 搞定HashMap 作为一个Java从业者,面试的时候肯定会被问到过HashMap,因为对于HashMap来说,可以说是Java集合中的精髓了,如果你觉得自己对它掌握的还不够好,我想今天这篇文章会非常适合你,至少,看了今天这篇文章,以后不怕面试被问HashMap了 其实在我学习HashMap的过程中,我个人觉得HashMap还是挺复杂的,如果真的想把它搞得明明白...
毕业5年,我问遍了身边的大佬,总结了他们的学习方法
我问了身边10个大佬,总结了他们的学习方法,原来成功都是有迹可循的。
python爬取百部电影数据,我分析出了一个残酷的真相
2019年就这么匆匆过去了,就在前几天国家电影局发布了2019年中国电影市场数据,数据显示去年总票房为642.66亿元,同比增长5.4%;国产电影总票房411.75亿元,同比增长8.65%,市场占比 64.07%;城市院线观影人次17.27亿,同比增长0.64%。 看上去似乎是一片大好对不对?不过作为一名严谨求实的数据分析师,我从官方数据中看出了一点端倪:国产票房增幅都已经高达8.65%了,为什...
推荐10个堪称神器的学习网站
每天都会收到很多读者的私信,问我:“二哥,有什么推荐的学习网站吗?最近很浮躁,手头的一些网站都看烦了,想看看二哥这里有什么新鲜货。” 今天一早做了个恶梦,梦到被老板辞退了。虽然说在我们公司,只有我辞退老板的份,没有老板辞退我这一说,但是还是被吓得 4 点多都起来了。(主要是因为我掌握着公司所有的核心源码,哈哈哈) 既然 4 点多起来,就得好好利用起来。于是我就挑选了 10 个堪称神器的学习网站,推...
这些软件太强了,Windows必装!尤其程序员!
Windows可谓是大多数人的生产力工具,集娱乐办公于一体,虽然在程序员这个群体中都说苹果是信仰,但是大部分不都是从Windows过来的,而且现在依然有很多的程序员用Windows。 所以,今天我就把我私藏的Windows必装的软件分享给大家,如果有一个你没有用过甚至没有听过,那你就赚了????,这可都是提升你幸福感的高效率生产力工具哦! 走起!???? NO、1 ScreenToGif 屏幕,摄像头和白板...
阿里面试,面试官没想到一个ArrayList,我都能跟他扯半小时
我是真的没想到,面试官会这样问我ArrayList。
曾经优秀的人,怎么就突然不优秀了。
职场上有很多辛酸事,很多合伙人出局的故事,很多技术骨干被裁员的故事。说来模板都类似,曾经是名校毕业,曾经是优秀员工,曾经被领导表扬,曾经业绩突出,然而突然有一天,因为种种原因,被裁员了,...
大学四年因为知道了这32个网站,我成了别人眼中的大神!
依稀记得,毕业那天,我们导员发给我毕业证的时候对我说“你可是咱们系的风云人物啊”,哎呀,别提当时多开心啦????,嗯,我们导员是所有导员中最帅的一个,真的???? 不过,导员说的是实话,很多人都叫我大神的,为啥,因为我知道这32个网站啊,你说强不强????,这次是绝对的干货,看好啦,走起来! PS:每个网站都是学计算机混互联网必须知道的,真的牛杯,我就不过多介绍了,大家自行探索,觉得没用的,尽管留言吐槽吧???? 社...
良心推荐,我珍藏的一些Chrome插件
上次搬家的时候,发了一个朋友圈,附带的照片中不小心暴露了自己的 Chrome 浏览器插件之多,于是就有小伙伴评论说分享一下我觉得还不错的浏览器插件。 我下面就把我日常工作和学习中经常用到的一些 Chrome 浏览器插件分享给大家,随便一个都能提高你的“生活品质”和工作效率。 Markdown Here Markdown Here 可以让你更愉快的写邮件,由于支持 Markdown 直接转电子邮...
看完这篇HTTP,跟面试官扯皮就没问题了
我是一名程序员,我的主要编程语言是 Java,我更是一名 Web 开发人员,所以我必须要了解 HTTP,所以本篇文章就来带你从 HTTP 入门到进阶,看完让你有一种恍然大悟、醍醐灌顶的感觉。 最初在有网络之前,我们的电脑都是单机的,单机系统是孤立的,我还记得 05 年前那会儿家里有个电脑,想打电脑游戏还得两个人在一个电脑上玩儿,及其不方便。我就想为什么家里人不让上网,我的同学 xxx 家里有网,每...
史上最全的IDEA快捷键总结
现在Idea成了主流开发工具,这篇博客对其使用的快捷键做了总结,希望对大家的开发工作有所帮助。
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
谁是华为扫地僧?
是的,华为也有扫地僧!2020年2月11-12日,“养在深闺人不知”的华为2012实验室扫地僧们,将在华为开发者大会2020(Cloud)上,和大家见面。到时,你可以和扫地僧们,吃一个洋...
AI 没让人类失业,搞 AI 的人先失业了
最近和几个 AI 领域的大佬闲聊 根据他们讲的消息和段子 改编出下面这个故事 如有雷同 都是巧合 1. 老王创业失败,被限制高消费 “这里写我跑路的消息实在太夸张了。” 王葱葱哼笑一下,把消息分享给群里。 阿杰也看了消息,笑了笑。在座几位也都笑了。 王葱葱是个有名的人物,21岁那年以全额奖学金进入 KMU 攻读人工智能博士,累计发表论文 40 余篇,个人技术博客更是成为深度学习领域内风向标。 ...
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆每天早上8:30推送 作者|Mr.K 编辑| Emma 来源|技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯...
作为一名大学生,如何在B站上快乐的学习?
B站是个宝,谁用谁知道???? 作为一名大学生,你必须掌握的一项能力就是自学能力,很多看起来很牛X的人,你可以了解下,人家私底下一定是花大量的时间自学的,你可能会说,我也想学习啊,可是嘞,该学习啥嘞,不怕告诉你,互联网时代,最不缺的就是学习资源,最宝贵的是啥? 你可能会说是时间,不,不是时间,而是你的注意力,懂了吧! 那么,你说学习资源多,我咋不知道,那今天我就告诉你一个你必须知道的学习的地方,人称...
立即提问

相似问题

1
wtforms FieldList 报错,求解?
0
flask + echarts 实现数据可视化jinja2模板页面报错但是可以运行?
1
微信小程序与flask服务器交互 wx.request
1
Python安装了Flask以后无法使用run()函数
1
flask接收前端的表单内容
1
flask中响应的http协议版本问题
2
jinja2.exceptions.TemplateNotFound: bootstrap/base.html的错误wen'ti
1
使用flask框架,后端向前端传值出现问题,前端未接受到后端的值,但抓包查看结果正确
1
python flask在主app.py文件中定义了一个工厂函数create_app(),并且创建列一个app实例,为什么还是会报Failed to find application in module "app"的错误。
1
在学习python flask migrate中,当在CMD中输入 python manager.py db migrate的时候,显示ImportError:DLL load failed,这个怎么解决?
2
python3.8用pyinstaller3.5导不出exe提示TypeError: an integer is required (got type bytes)
1
flask+mysql实现的web应用,在注册页面点击注册后提示 Instance '<User at 0x5486a10>' has been deleted?
1
部署flask项目到heroku上时,出现psycopg2.errors.UndefinedTable: relation "question" does not exist问题,该怎么解决?
1
利用flask+celery+flask_mail扩展异步发送邮件时,celery会出现上下文问题,有人能解决吗?网上找了很多,都感觉很模糊
1
flask蓝图模式下,怎么使用pymongo
0
python flask_sqlalchemy如何维护一个全局查询结果
0
Python中用flask怎么将HTML中模拟的数据替换为自己MySQL中的数据。
0
为什么我的pyecharts柱形图表部署在flask后,横坐标由原来的文字标签变成数字了?
1
Flask使用不了服务器80端口
0
flask中sqlalchemy中的异常都有哪些?继承的父类异常是什么