Please help me to find variable that has my current site IP and port
frappe.utils.get_url()
Returns: erpnext.vm
Is not OK for me, I need IP and PORT:
Example:
Please help me to find variable that has my current site IP and port
frappe.utils.get_url()
Returns: erpnext.vm
Is not OK for me, I need IP and PORT:
Example:
You can use window.location to get host
and port
in frappe module? How to call it?
In [3]: import frappe.window.location
ImportError Traceback (most recent call last)
/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.pyc in ()
----> 1 import frappe.window.location
ImportError: No module named window.location
window.location
is javascript
try frappe.request.url
in Python
Not working for me. Look please to my error:
In [1]: from frappe import request
In [2]: print request.url
RuntimeError Traceback (most recent call last)
/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.pyc in ()
1 print request.url
/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/werkzeug/local.pyc in getattr(self, name)
341 if name == βmembersβ:
342 return dir(self._get_current_object())
β 343 return getattr(self._get_current_object(), name)
344
345 def setitem(self, key, value):
/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/werkzeug/local.pyc in _get_current_object(self)
304 return getattr(self.__local, self.name)
305 except AttributeError:
β 306 raise RuntimeError(βno object bound to %sβ % self.name)
307
308 @property
RuntimeError: no object bound to request
request wonβt work in python console it is werkzeug.local.LocalProxy
Oh but canβt find PORT and IP:
In [2]: import werkzeug
In [3]: print werkzeug.local.LocalProxy
<class βwerkzeug.local.LocalProxyβ>
In [4]: print dir(werkzeug.local.LocalProxy)
[β_LocalProxy__localβ, βabsβ, βaddβ, βandβ, βcallβ, βclassβ, βcmpβ, βcoerceβ, βcomplexβ, βcontainsβ, βcopyβ, βdeepcopyβ, βdelattrβ, βdelitemβ, βdelsliceβ, βdictβ, βdirβ, βdivβ, βdivmodβ, βdocβ, βenterβ, βeqβ, βexitβ, βfloatβ, βfloordivβ, βformatβ, βgeβ, βgetattrβ, βgetattributeβ, βgetitemβ, βgetsliceβ, βgtβ, βhashβ, βhexβ, βindexβ, βinitβ, βintβ, βinvertβ, βiterβ, βleβ, βlenβ, βlongβ, βlshiftβ, βltβ, βmodβ, βmoduleβ, βmulβ, βnameβ, βneβ, βnegβ, βnewβ, βnonzeroβ, βoctβ, βorβ, βposβ, βpowβ, βraddβ, βrdivβ, βrdivmodβ, βreduceβ, βreduce_exβ, βreprβ, βrfloordivβ, βrmodβ, βrmulβ, βrshiftβ, βrsubβ, βrtruedivβ, βsetattrβ, βsetitemβ, βsetsliceβ, βsizeofβ, βslotsβ, βstrβ, βsubβ, βsubclasshookβ, βtruedivβ, βunicodeβ, βxorβ, β_get_current_objectβ]
frappe.request.url
is just a string.
In [1]: from urlparse import urlparse
In [2]: url1 = "http://67.89.12.89:8000"
In [3]: url0 = "http://192.168.88.182:8000"
In [4]: parsed_url1 = urlparse(url1)
In [5]: parsed_url1
Out[5]: ParseResult(scheme=u'http', netloc=u'67.89.12.89:8000', path=u'', params='', query='', fragment='')
In [6]: parsed_url1.netloc
Out[6]: u'67.89.12.89:8000'
In [7]: parsed_url1.netloc.split(":")
Out[7]: [u'67.89.12.89', u'8000']
In [8]: parsed_url0 = urlparse(url0)
In [9]: parsed_url0.netloc.split(":")
Out[9]: [u'192.168.88.182', u'8000']