我正在尝试Django框架,我会分享/展示/展示我给我的同事/朋友做的一些事情.我通过VMware在Win7下的Ubuntu工作.所以我的愿望/愿望是将我当前的pub-IP与端口(例如http://123.123.123.123:8181/django-app/)发送给我的朋友,以便他们可以测试它.
问题是 - 我使用django的开发服务器(python /path-to-django-app/manage.py runserver $ IP:$ PORT).
如何将devserver公开?
编辑:
哦,有些事我忘了提.我很难过,我将VMware与Ubuntu一起使用.我有一个shellcript,它返回我当前的int-IP 192.168.xx.xx并将其保存在环境变量($ CUR_IP)中所以,每次我想运行django的devserver我只需执行
python /path-to-django-site/manage.py runserver $CUR_IP:8080
Run Code Online (Sandbox Code Playgroud)
通过这种方式,我成为了一个http-adress(例如http://192.168.40.145:8080/app-name/),我可以在我的虚拟机外面使用它.我可以在我的主机(win7)机器上测试它.这就是我问这个问题的原因.我认为有一种方法可以使用ext-IP并使runserver也可以在外面使用
我如何拒绝访问http://sub.mydomain.com/,但允许(完全)http://sub.mydomain.com/test(或http://sub.mydomain.com/test/)
http://sub.mydomain.com/test/后面有一个magento后端
问题:我得到一个AJAX响应(带换行符的JSON或明文).应通过RegEx检查每个响应项,以确定它是否与用户定义的模式匹配.
例:
Ajax响应(纯文本)
"Aldor
Aleph
Algae
Algo
Algol
Alma-0
Alphard
Altran"
Run Code Online (Sandbox Code Playgroud)
用户模式:
/^Alg/ig.test(responseItem)
Run Code Online (Sandbox Code Playgroud)
RegExp结果应如下所示:
Aldor // false
Aleph // false
Algae // true
Algo // true
Algol // true
Alma-0 // false
Alphard // false
Altran // false
Run Code Online (Sandbox Code Playgroud)
但每次我得到不同(和有点受欢迎)的结果......例如(/^alg/ig.test("Algo")=> false)
我的代码:
HTML
...
<form>
<input id="in" />
</form>
<div id="x">
Aldor
Aleph
Algae
Algo
Algol
Alma-0
Alphard
Altran
</div><button id="checker">check!</button>
...
Run Code Online (Sandbox Code Playgroud)
JavaScript(jQuery 1.6.2)
$(function(){
var $checker = $('#checker');
$checker.click(function(ev){
var inputFieldVal = $.trim($('#in').val());
console.log(inputFieldVal); // Alg
var …Run Code Online (Sandbox Code Playgroud) 是否有可能在LINQ查询中获取当前的枚举器(...或迭代器?不知道哪个是正确的)?
例如,我尝试创建所有当前加载的程序集的XML输出(通过LINQ to XML).
Dim xmldoc As XDocument = New XDocument(
New XElement("Types",
Assembly.GetExecutingAssembly().GetReferencedAssemblies() _
.Select(Function(name) Assembly.Load(name)) _
.SelectMany(Function(assembly) assembly.GetTypes()) _
.Select(Function(type) New XElement("Type", type.FullName))))
Run Code Online (Sandbox Code Playgroud)
输出看起来像这样.
<Types>
<Type>System.Object</Type>
<Type>FXAssembly</Type>
<Type>ThisAssembly</Type>
<Type>AssemblyRef</Type>
<Type>System.Runtime.Serialization.ISerializable</Type>
<Type>System.Runtime.InteropServices._Exception</Type>
.....
</Types>
Run Code Online (Sandbox Code Playgroud)
是否有可能以某种方式从LINQ的选择中获得当前的"索引"(计数器?)?我想在XML中使用它
<Types>
<Type ID="1">System.Object</Type>
<Type ID="2">FXAssembly</Type>
<Type ID="3">ThisAssembly</Type>
<Type ID="4">AssemblyRef</Type>
<Type ID="or-some-other-unique-id-#5">System.Runtime.Serialization.ISerializable</Type>
.....
</Types>
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个简单的AJAX(通过jQuery)请求到http:// yourusername .couchone.com /(就像我在localhost上安装了couchdb一样)
如果我http://**yourusername**.couchone.com/通过浏览器,我会得到:
{"couchdb":"Welcome","version":"1.0.1"}所以,它看起来像一个序列化的JSON.
所以我写了一个JS代码:
$(function() {
$.getJSON('http://www.********.couchone.com/', function(data) {
console.log(data.couchdb);
console.log(data.version);
});
});
Run Code Online (Sandbox Code Playgroud)
但代码不起作用.FireBug的控制台显示GET请求没有响应(整行是红色的)我能看到的一切都是Request-Header和Response-Header,但没有DATA(作为响应)
请求标题:
Host : www.*******.couchone.com
User-Agent : Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10 FirePHP/0.4
Accept : application/json, text/javascript, */*
Accept-Language : de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding : gzip,deflate
Accept-Charset : ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive : 115
Connection : keep-alive
Origin : null
Run Code Online (Sandbox Code Playgroud)
响应标题:
Server : CouchDB/1.0.1 (Erlang OTP/R13B)
Date : Sun, 26 Sep 2010 12:45:47 GMT
Content-Type : application/json
Content-Length : 40 …Run Code Online (Sandbox Code Playgroud)