Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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


How to get Host IP address or DNS name in the container code

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.
Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp