- Notifications
You must be signed in to change notification settings - Fork23
HowTo | Misc
ML-TANGO edited this pageOct 14, 2022 ·1 revision
In this wiki page, we archive code snippets for simple but common implementaion questions
Front end, Javascript
functionDataMain(){const[server_ip,setServer_ip]=useState();/* 페이지 로드 완료시 호출 이벤트 */useEffect(()=>{varhost=window.location.hostnamesetServer_ip('http://'+host+':8086')},[]);
Back end, Python
*[example code in project_manager/tango/viewsProject.py](https://github.com/ML-TANGO/TANGO/blob/teslasystem/project_manager/tango/viewsProject.py#L36
defget_server_ip(request):try:# weda_port_num = 8090# return Response({'port': weda_port_num})s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)s.connect(("8.8.8.8",80))print(s.getsockname()[0])host=s.getsockname()[0]returnResponse({'host':host})exceptExceptionase:print(e)
👉Note
- This page might contain some wide rendered images. If you want to see the whole contents with wider page, please useWide GitHub extension of Chrome.
- If you are experiencing the error on rendered images due to the low-bandwith Internet delay, please use F5 function key for refreshing current page.