Search code examples
pythonpython-3.xmodel-view-controllersyntaxpython-class

Syntax error When I try to run backend code


When I try to run the server I get syntax error. But there isn`t any incorrect using of syntax. Please help to correct this issue! Issue image

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':'Неверный логин или пароль'}"

Solution

  • It looks like you are missing the async keyword before def index(self):

    Another bug I can see is that you are not binding the parameters to your patients method correctly from the @post decorator.