File tree Expand file tree Collapse file tree 6 files changed +104
-1
lines changed
Expand file tree Collapse file tree 6 files changed +104
-1
lines changed Original file line number Diff line number Diff line change 2121build
2222app.spec
2323design_plan.md
24- frontend
24+ frontend /test.html
25+ frontend /test_index.html
Original file line number Diff line number Diff line change 11from core .logging import setup_logging
2+ from core .utils import frontend_path
23from api .system import router as system_router
34from api .auth import router as auth_router
45from api .lecture_content import router as lec_content_router
1920
2021logger .info ("Application startup complete" )
2122
23+ static_dir = frontend_path ()
24+
25+ app .mount ("/static" , StaticFiles (directory = static_dir ), name = "static" )
26+
27+
28+ @app .get ("/" , include_in_schema = False )
29+ def serve_frontend ():
30+ return FileResponse (os .path .join (static_dir , "index.html" ))
31+
32+
2233# Include routers
2334app .include_router (system_router , prefix = "/api" )
2435app .include_router (auth_router , prefix = "/api" )
Original file line number Diff line number Diff line change 22from pathlib import Path
33from dotenv import load_dotenv , set_key
44from typing import Any , Optional
5+ import sys
56
67ENV_PATH = ".env"
78
@@ -56,3 +57,15 @@ def standard_response(
5657 "data" : data if success else None ,
5758 "status_code" : status_code ,
5859 }
60+
61+
62+ def resource_path (path ):
63+ if hasattr (sys , "_MEIPASS" ):
64+ return os .path .join (sys ._MEIPASS , path )
65+ return os .path .join (os .path .abspath ("." ), path )
66+
67+
68+ def frontend_path ():
69+ if hasattr (sys , "_MEIPASS" ):
70+ return resource_path ("frontend" )
71+ return "frontend"
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7+ < title > pw-client</ title >
8+
9+ </ head >
10+
11+ < body >
12+ < h1 > -- IN PROGRESS --</ h1 >
13+ </ body >
14+
15+ </ html >
Original file line number Diff line number Diff line change 1+ import os , ctypes
2+ from app import app
3+ import uvicorn
4+
5+
6+ def enable_vt100 ():
7+ if os .name == "nt" :
8+ kernel32 = ctypes .windll .kernel32
9+ handle = kernel32 .GetStdHandle (- 11 )
10+ mode = ctypes .c_uint ()
11+ kernel32 .GetConsoleMode (handle , ctypes .byref (mode ))
12+ kernel32 .SetConsoleMode (handle , mode .value | 0x0004 )
13+
14+
15+ enable_vt100 ()
16+ os .environ ["NO_COLOR" ] = "1"
17+ os .environ ["UVICORN_NO_COLOR" ] = "1"
18+
19+
20+ if __name__ == "__main__" :
21+ port = int (os .environ .get ("PORT" , 8000 ))
22+ uvicorn .run (app , host = "0.0.0.0" , port = port )
Original file line number Diff line number Diff line change 1+ import sys
2+ from PyInstaller .utils .hooks import collect_submodules
3+
4+ hidden = collect_submodules ('fastapi' ) + collect_submodules ('uvicorn' )
5+
6+ block_cipher = None
7+
8+ a = Analysis (
9+ ['launcher.py' ],
10+ pathex = ['.' ],
11+ binaries = [],
12+ datas = [
13+ ('frontend' , 'frontend' ),
14+ ('schema' , 'schema' ),
15+ ('frontend/src/favicon.ico' , 'frontend/src' ),
16+ ],
17+ hiddenimports = hidden ,
18+ hookspath = [],
19+ runtime_hooks = [],
20+ excludes = [],
21+ win_no_prefer_redirects = False ,
22+ win_private_assemblies = False ,
23+ cipher = block_cipher ,
24+ )
25+
26+ pyz = PYZ (a .pure , a .zipped_data , cipher = block_cipher )
27+
28+ exe = EXE (
29+ pyz ,
30+ a .scripts ,
31+ a .binaries ,
32+ a .zipfiles ,
33+ a .datas ,
34+ name = 'pw-client' ,
35+ debug = False ,
36+ strip = False ,
37+ upx = False ,
38+ console = True ,
39+ icon = 'frontend/src/favicon.ico' ,
40+ )
41+
You can’t perform that action at this time.
0 commit comments