Flask application built using pyinstaller not rendering index.html

前端 未结 5 638
面向向阳花
面向向阳花 2020-12-25 15:19

I have written a flask application and it works perfectly fine. I wanted to distribute it as an executable. Tried doing it using pyinstaller flaskScript.py dist folder got

5条回答
  •  Happy的楠姐
    2020-12-25 16:03

    if getattr(sys, 'frozen', False):                                                                                                                                     
          template_folder = os.path.join(sys.executable, '..','templates')                                                                                                  
          static_folder = os.path.join(sys.executable, '..','static')                                                                                                       
          app = Flask(__name__, template_folder = template_folder,\                                                                                                         
                                  static_folder = static_folder)
    

    copy this code and paste in your file. now pyinstaller looks for static and template folder in your dist directory. Now copy and paste static and template folder in your dist folder. it will works

提交回复
热议问题