#!/usr/bin/env python # -*- coding: utf-8 -*- # @Project : Python. # @File : 7_登录 # @Time : 2023/3/14 下午4:02 # @Author : yuanjie # @WeChat : meutils # @Software : PyCharm # @Description : import wenxin_api from wenxin_api.tasks.text_to_image import TextToImage import streamlit as st import streamlit_authenticator as stauth from streamlit_authenticator import Authenticate # ME from meutils.pipe import * st.set_page_config(page_title="文本标注平台", page_icon=":rainbow:", layout="centered", initial_sidebar_state="auto") # 如下代码数据,可以来自数据库 admin_password = '123456' _ = f""" credentials: usernames: admin: email: admin@gmail.com name: admin password: {stauth.Hasher([admin_password]).generate()[0]} # To be replaced with hashed password cookie: expiry_days: 30 key: some_signature_key name: some_cookie_name preauthorized: emails: - 313303303@qq.com """ config = yaml.safe_load(_) authenticator = Authenticate( config['credentials'], config['cookie']['name'], config['cookie']['key'], config['cookie']['expiry_days'], config['preauthorized'] ) name, authentication_status, username = authenticator.login('图像生成系统', 'main') if authentication_status: authenticator.logout('退出', 'sidebar') st.write('# 图像生成系统') elif authentication_status == False: st.error('Username/password is incorrect') # elif authentication_status == None: # st.warning('Please enter your username and password')