【问题标题】:Syntax error When I try to run backend code当我尝试运行后端代码时出现语法错误
【发布时间】:2021-08-18 19:47:16
【问题描述】:

当我尝试运行服务器时,出现语法错误。但是没有任何不正确的语法使用。请帮助纠正这个问题! 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':'Неверный логин или пароль'}"

【问题讨论】:

    标签: python python-3.x model-view-controller syntax python-class


    【解决方案1】:

    您似乎在def index(self): 之前缺少async 关键字

    我可以看到的另一个错误是您没有从 @post 装饰器正确地将参数绑定到您的 patients 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-26
      • 2021-12-24
      • 2014-05-13
      • 2022-11-07
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 2020-02-11
      相关资源
      最近更新 更多