| skipped 133 lines |
134 | 134 | | return how |
135 | 135 | | |
136 | 136 | | try: |
137 | | - | if sys.argv[1]=="ipynb": |
| 137 | + | run_type=sys.argv[1] |
| 138 | + | if run_type=="ipynb": |
138 | 139 | | host_ip="127.0.0.1" |
139 | 140 | | host_port=1000 |
140 | | - | else: |
| 141 | + | elif run_type=="docker": |
141 | 142 | | host_ip="0.0.0.0" |
142 | 143 | | host_port=8080 |
| 144 | + | elif run_type=="local": |
| 145 | + | host_ip="127.0.0.1" |
| 146 | + | host_port=8080 |
| 147 | + | else: |
| 148 | + | exit() |
143 | 149 | | except: |
144 | | - | host_ip="127.0.0.1" |
145 | | - | host_port=8080 |
| 150 | + | print(f"USAGE : python3 {sys.argv[0]} <ipynb/docker/local>") |
146 | 151 | | |
147 | 152 | | #iswork: |
148 | 153 | | @eel.expose |
149 | 154 | | def iswork(): |
150 | 155 | | return "True" |
151 | 156 | | |
152 | | - | print(f"hiphp-dst run on : {host_ip}:{host_port}") |
| 157 | + | print(f"hiphp-dst run on : {run_type}@{host_ip}:{host_port}") |
| 158 | + | |
| 159 | + | if run_type=="docker": |
| 160 | + | import socket |
| 161 | + | ip_address = socket.gethostbyname(socket.gethostname()) |
| 162 | + | print(f"Listening on {ip_address}:{host_port}") |
153 | 163 | | |
154 | 164 | | #eel.start("index.html",host=host_ip,port=host_port,size=(1050,500)) |
155 | | - | try: |
156 | | - | if sys.argv[1]=="ipynb": |
157 | | - | from pyngrok import ngrok |
| 165 | + | if run_type=="ipynb": |
| 166 | + | from pyngrok import ngrok |
| 167 | + | |
| 168 | + | try: |
| 169 | + | auth_token=sys.argv[2] |
| 170 | + | except: |
| 171 | + | print(f"USAGE : python3 {sys.argv[0]} <ipynb> <auth_token>") |
| 172 | + | exit() |
158 | 173 | | |
159 | | - | ngrok.set_auth_token(sys.argv[2]) |
160 | | - | public_url = ngrok.connect(host_port).public_url |
161 | | - | print(f"Sharing app at {public_url}") |
162 | | - | eel.start("index.html",host=host_ip,port=host_port) |
163 | | - | with True: |
164 | | - | pass |
| 174 | + | ngrok.set_auth_token(auth_token) |
| 175 | + | public_url = ngrok.connect(host_port).public_url |
| 176 | + | print(f"Sharing app at {public_url}") |
| 177 | + | eel.start("index.html",host=host_ip,port=host_port) |
| 178 | + | with True: |
| 179 | + | pass |
165 | 180 | | |
166 | | - | print("Killing streamlit app") |
167 | | - | print("Killing ngrok tunnel") |
168 | | - | ngrok.kill() |
169 | | - | raise |
170 | | - | except: |
| 181 | + | print("Killing streamlit app") |
| 182 | + | print("Killing ngrok tunnel") |
| 183 | + | ngrok.kill() |
| 184 | + | raise |
| 185 | + | else: |
171 | 186 | | eel.start("index.html",host=host_ip,port=host_port,mode='default') |
172 | 187 | | #}END. |
173 | 188 | | |