-
Notifications
You must be signed in to change notification settings - Fork 20
HowTo | Misc
ML-TANGO edited this page Oct 14, 2022
·
1 revision
In this wiki page, we archive code snippets for simple but common implementaion questions
Front end, Javascript
function DataMain()
{
const [server_ip, setServer_ip] = useState();
/* 페이지 로드 완료시 호출 이벤트 */
useEffect( () =>
{
var host = window.location.hostname
setServer_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
def get_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]
return Response({'host': host})
except Exception as e:
print(e)
👉Note
- This page might contain some wide rendered images. If you want to see the whole contents with wider page, please use Wide 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.