Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 尝试运行后端代码时出现语法错误_Python_Python 3.x_Model View Controller_Syntax_Python Class - Fatal编程技术网

Python 尝试运行后端代码时出现语法错误

Python 尝试运行后端代码时出现语法错误,python,python-3.x,model-view-controller,syntax,python-class,Python,Python 3.x,Model View Controller,Syntax,Python Class,当我尝试运行服务器时,出现语法错误。但是没有任何不正确的语法用法。请帮助更正此问题 看起来您缺少def index(self): 我能看到的另一个错误是,您没有从@post装饰程序将参数正确绑定到患者方法。谢谢!这是非常有益的! from blacksheep.server.application import Application from blacksheep.server.controllers import Controller, get, post from blacksheep.c

当我尝试运行服务器时,出现语法错误。但是没有任何不正确的语法用法。请帮助更正此问题


看起来您缺少
def index(self):


我能看到的另一个错误是,您没有从
@post
装饰程序将参数正确绑定到
患者
方法。

谢谢!这是非常有益的!
from blacksheep.server.application import Application
from blacksheep.server.controllers import Controller, get, post
from blacksheep.cookies import Cookie
from blacksheep.messages import Response
from easy_cryptography.hash.hash_funct import compare_hash
from app.configuration import AUTHORIZED
from models import Doctors
from pony.orm import *

class Home(Controller):
    
    @get("/")
    def index(self):
        return self.view()

class Patients(Controller):

    @post("/patients")
    def patients(self, login: str, password: str):
        if Doctors.exists(login) and (compare_hash(password, Doctors.get_for_update(login = login).password)):
            patients = Patients.select()
            response = self.view(patients=patients)
            response.set_cookie(Cookie(AUTHORIZED,True))
            return response
        else:
            return "{'message':'Неверный логин или пароль'}"