我在Python上创建了一个简单的webservice应用程序,它公开了另一个类中的一些Python函数。当我向localhost发起一个请求时,它连接到API,公开的函数按它的预期执行,但是任何后续的请求都会导致错误。在
这是我的代码:
网络服务.py
#!flask/bin/python
from flask import Flask
from flask import request
import sys
sys.path.append('/src/')
from encrypto import Encrypto
app = Flask(__name__)
@app.route('/call/<function_name>/<arg>', methods=['GET'])
def callFunction(function_name: str, arg: str):
functionToCall = getattr(Encrypto(), function_name)
return str(functionToCall(arg))
if __name__ == '__main__':
app.run(host='localhost', threaded=True)
以下是我运行的演示:
^{pr2}$它会导致以下错误:
Error HTTPSConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /call/encrypt/oranges (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",),)): Could not access this url: https://localhost:5000/call/encrypt/oranges
Error HTTPSConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /call/decrypt/apples (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'unknown protocol')],)",),)): Could not access this url: https://localhost:5000/call/decrypt/apples
[('http://localhost:5000/call/encrypt/blahblah', b'1011989968'), ('https://localhost:5000/call/encrypt/oranges', ''), ('https://localhost:5000/call/decrypt/apples', '')]
从上面的输出中可以看到,后面的两个API调用返回一个空字符串,表示错误。在
目前没有回答
相关问题 更多 >
编程相关推荐