๊ด€๋ฆฌ ๋ฉ”๋‰ด

ruriruriya

[Python] ํŒŒ์ด์ฌ ์ŠคํŠธ๋ฆผ๋ฆฟ(Streamlit) - ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ๋ฐ›๊ณ  ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•(text_input(type='password'), secrets) ๋ณธ๋ฌธ

๐ŸPython/Streamlit

[Python] ํŒŒ์ด์ฌ ์ŠคํŠธ๋ฆผ๋ฆฟ(Streamlit) - ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ๋ฐ›๊ณ  ์ €์žฅํ•˜๋Š” ๋ฐฉ๋ฒ•(text_input(type='password'), secrets)

๋ฃจ๋ฆฌ์•ผใ…‘ 2023. 11. 26. 00:17
๋ฐ˜์‘ํ˜•

๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๋Š” ๊ฒƒ์€ ์‚ฌ์šฉ์ž์˜ ๊ฐœ์ธ ์ •๋ณด๋ฅผ ๋ณดํ˜ธํ•˜๋Š” ๋ฐ ์ค‘์š”ํ•œ ๋ถ€๋ถ„์ด๋‹ค. Streamlit์—์„œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ์ž…๋ ฅ๋ฐ›์œผ๋ ค๋ฉด text_input์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž…๋ ฅ์„ ๋ฐ›๊ณ , st.secrets๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ˆจ๊ธฐ๋Š” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅ๋ฐ›๊ณ  ์ด๋ฅผ st.secrets๋ฅผ ํ†ตํ•ด ์•ˆ์ „ํ•˜๊ฒŒ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ์ž…๋ ฅํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋Š” ํ™”๋ฉด์— ํ‘œ์‹œ๋˜์ง€ ์•Š๋Š”๋‹ค. ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ €์žฅํ•  ๋•Œ๋Š” ์•”ํ˜ธํ™”๋œ ํ˜•ํƒœ๋กœ ์ €์žฅ๋˜์–ด ๋ณด์•ˆ์ด ๊ฐ•ํ™”๋œ๋‹ค.

import streamlit as st
def main():

password =st.text_input('๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ', type='password')

    if password:
        st.secrets["user_password"] = password
        st.success("๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์•ˆ์ „ํ•˜๊ฒŒ ์ €์žฅ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
        
if __name__ == '__main__':
    main()

 

[๋ธŒ๋ผ์šฐ์ € ํ™”๋ฉด]

๋ˆˆ์„ ์ผฐ์„ ๋•Œ

๋ฐ˜์‘ํ˜•