File tree Expand file tree Collapse file tree 8 files changed +63
-0
lines changed
tutorial-reference/Day_28 Expand file tree Collapse file tree 8 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ .\Scripts\activate
2+ pyinstaller src/ wsgi.py -F `
3+ -- name " cfe-os-windows" `
4+ -- icon= ' icon.ico' `
5+ -- add-data " src\data\*;data" `
6+ -- add-data " src\data\*.jpg;data" `
7+ -- hidden - import waitress `
8+ -- clean
Original file line number Diff line number Diff line change 1+ source bin/activate
2+ pyinstaller src/wsgi.py -F \
3+ --name " cfe-os-mac" \
4+ --icon=' icon.icns' \
5+ --add-binary=' /System/Library/Frameworks/Tk.framework/Tk' :' tk' \
6+ --add-binary=' /System/Library/Frameworks/Tcl.framework/Tcl' :' tcl' \
7+ --add-data " src/data/*:data" \
8+ --add-data " src/data/*.jpg:data" \
9+ --hidden-import waitress \
10+ --clean
Original file line number Diff line number Diff line change 1+ home = /usr/local/bin
2+ include-system-site-packages = false
3+ version = 3.6.8
Original file line number Diff line number Diff line change 1+ from .main import *
Original file line number Diff line number Diff line change 1+ import pathlib
2+ from flask import Flask
3+
4+ from .resources import get_resource_path
5+ BASE_DIR = pathlib .Path (__file__ ).resolve ().parent
6+ DATA_DIR = get_resource_path ("data" )
7+ IMG_PATH = DATA_DIR / 'beach.jpg'
8+ web_app = Flask (__name__ )
9+
10+ @web_app .route ("/" , methods = ['GET' ]) #http://localhost:5000/
11+ def index ():
12+ return {"dir" : str (BASE_DIR ),
13+ 'data_dir' : str (DATA_DIR ),
14+ 'IMG_PATH' : IMG_PATH .exists ()
15+ }, 200
16+
Original file line number Diff line number Diff line change 1+ import pathlib
2+ import sys
3+
4+
5+ def get_resource_path (relative_path ):
6+ """
7+ relative_path = "data/beach.jpg"
8+ relative_path = pathlib.Path("data") / "beach.jpg"
9+ relative_path = os.path.join("data", "beach.jpg")
10+ """
11+ rel_path = pathlib .Path (relative_path )
12+ dev_base_path = pathlib .Path (__file__ ).resolve ().parent .parent
13+ base_path = getattr (sys , "_MEIPASS" , dev_base_path )
14+ return base_path / rel_path
Original file line number Diff line number Diff line change 1+ from cfe_os import web_app
2+ from waitress import serve
3+
4+
5+ if __name__ == "__main__" :
6+ serve (
7+ web_app ,
8+ host = '127.0.0.1' ,
9+ port = 5002 ,
10+ threads = 2
11+ )
You can’t perform that action at this time.
0 commit comments