我正在尝试运行一个以资源和帐户作为参数的Web服务并返回用户密码,但它会返回一些错误:
raise ValueError('View function did not return a response')
ValueError: View function did not return a response
这是我的代码的结构:
from flask import Flask
import requests
# Config
TOKEN = ""
SERVER = ""
# Classes
class PClient():
def __init__(self, token=TOKEN, server=SERVER):
self.token = token
self.server = server
self.cache = {}
pass
def getPassword(self, resource, account):
if resource in self.cache and account in self.cache[resource]:
return self.cache[resource][account]
else :
return "Something"
# Script
app = Flask(__name__)
pmp = PClient()
@app.route('/<string:resource>/<string:account>')
def get_password(resource, account):
global pmp
return pmp.getPassword(resource, account)
if __name__ == "__main__":
app.run(host="127.0.0.1", port=2999, debug=True)
任何想法? 谢谢