コード例 #1
0
ファイル: app.py プロジェクト: zlind1/games
def user(user_id):
    if request.method == 'GET':
        return User.get(user_id)
    if request.method == 'PUT':
        user = User.get(user_id)
        user.username = request.json['username']
        user.password = request.json['password']
        return user.update()
    if request.method == 'DELETE':
        return User.delete(user_id)
コード例 #2
0
def login():
    if request.method == "POST":
        name = request.form['username']
        password = request.form['password']

        try:
            user = User.get(User.username == name)
            if check_password_hash(user.password, password):
                # flash("Loggin Successful!")
                session['logged_in'] = True
                session['username'] = name
                return redirect(url_for('home'))
        except User.DoesNotExist:
            flash("Invalid username or password")
    return render_template("login.html")
コード例 #3
0
ファイル: server.py プロジェクト: rebryk/vrp-server
    async def recognize_audio(self, url, user_id):
        user = None

        if user_id:
            user = User.get(id=user_id) or User(id=user_id, uuid=uuid.uuid4())

        # return text if audio was recognized before
        if self.use_cache:
            audio = Audio.get(url=url)

            if audio and audio.text is not None:
                return audio.text

        text = await self.asr.recognize(url, user.uuid if user else None)

        try:
            if self.use_cache:
                Audio(url=url, text=text, user=user)
        except Exception as e:
            self.logger.error("Failed to insert audio: {}".format(str(e)))

        return text