CoolFace
Apppublic

ginigen/webtoon-studio

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
3likes
app.py35 linesDownload Raw Back to root
1import os2import sys3import streamlit as st4from tempfile import NamedTemporaryFile5 6def main():7    try:8        # Get the code from secrets9        code = os.environ.get("MAIN_CODE")10        11        if not code:12            st.error("⚠️ The application code wasn't found in secrets. Please add the MAIN_CODE secret.")13            return14        15        # Create a temporary Python file16        with NamedTemporaryFile(suffix='.py', delete=False, mode='w') as tmp:17            tmp.write(code)18            tmp_path = tmp.name19        20        # Execute the code21        exec(compile(code, tmp_path, 'exec'), globals())22        23        # Clean up the temporary file24        try:25            os.unlink(tmp_path)26        except:27            pass28            29    except Exception as e:30        st.error(f"⚠️ Error loading or executing the application: {str(e)}")31        import traceback32        st.code(traceback.format_exc())33 34if __name__ == "__main__":35    main()