烧瓶:当我导入请求时,为什么我的服务器停滞不前?
方案
我正在使用python烧结服务器从远程数据库中提供数据。我很想使用请求
框架与持有连接连接到我的数据库。
使用的技术
- python 3.10
- 烧瓶 2.0.3
- 诗歌 1.0(对于依赖项)
- 请求 2.28.1(添加诗歌)
- IBM代码引擎(云平台/环境)
exudy
我的项目正常工作,直到我添加行import import import请求
在我的server.py.py
的顶部。当我添加此行时,我的服务器没有给出任何响应,并且会出来。
代码
以下输出
{“ Hello”:“ WHINE”}
,因为import requests
未添加。
import os
import sys
import json
from collections import Counter
from flask import Flask, render_template, request, session, url_for, jsonify
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def main():
return { 'hello': "there" }
if __name__ == 'main':
app.run()
以下失速和服务器没有响应,因为
导入请求
已添加。
import os
import sys
import json
import requests # adding this
from collections import Counter
from flask import Flask, render_template, request, session, url_for, jsonify
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def main():
return { 'hello': "there" }
if __name__ == 'main':
app.run()
问题
为什么我不能导入请求,如果我缺少某些内容,请您留下有关我需要做什么以使此工作的答案?
(我注意到其他一些框架也不能导入)
SCENARIO
I am using a python flask server to serve up data from my remote database. I am tempting to use the requests
framework to connect to my database with a held connection.
TECHNOLOGY USED
- Python 3.10
- Flask 2.0.3
- Poetry 1.0 (for dependencies)
- Requests 2.28.1 (added with Poetry)
- IBM Code Engine (cloud platform/environment)
ISSUE
My project works just fine up until I add the line import request
at the top of my server.py
. When I add this line no responses are given by my server and it times out.
CODE
The below outputs
{ "hello": "there" }
, becauseimport requests
was not added.
import os
import sys
import json
from collections import Counter
from flask import Flask, render_template, request, session, url_for, jsonify
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def main():
return { 'hello': "there" }
if __name__ == 'main':
app.run()
The below stalls and servers no response, because
import requests
was added.
import os
import sys
import json
import requests # adding this
from collections import Counter
from flask import Flask, render_template, request, session, url_for, jsonify
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def main():
return { 'hello': "there" }
if __name__ == 'main':
app.run()
QUESTION
Why can't I import requests, and if I'm missing something could you please leave a code answer as to what I need to do to get this working?
(I've noticed some other frameworks can't be imported either)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论