python代码

def nginxbj(request):
    id1 = request.GET['id'] 
    host_list = get_object_or_404(NginxET, pk=id1)
    form = HostsListForm(instance=host_list)
    action='edit'
    page_name="编辑配置文件"
    ret = NginxET.objects.values_list('message', flat=True).get(id=id1)

    return render_to_response('nginxbianji.html',
           {'ret': ret, 'id1': id1},context_instance=RequestContext(request))

def nginxbjh(request):
    id1 = request.GET['id'] 
    host_list = get_object_or_404(NginxEThistory, pk=id1)
    form = HostsListForm(instance=host_list)
    action='edit'
    page_name="编辑配置文件"
    ret = NginxEThistory.objects.values_list('message', flat=True).get(id=id1)

    return render_to_response('nginxbianji.html',
           {'ret': ret, 'id1': id1},context_instance=RequestContext(request))

html代码

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!-- Favicon -->
    <link rel="shortcut icon" href="/static/img/favicon.ico" type="p_w_picpath/x-icon">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="/static/plugins/bootstrap/css/bootstrap.min.css">
    <!-- Fonts from Font Awsome -->
    <link rel="stylesheet" href="/static/css/font-awesome.min.css">
    <!-- CSS Animate -->
    <link rel="stylesheet" href="/static/css/animate.css">
    <!-- Custom styles for this theme -->
    <link rel="stylesheet" href="/static/css/main.css"> 
<meta name="robots" content="all" />
<meta name="author" content="w3school.com.cn" />

<link rel="stylesheet" type="text/css" href="/tiy/tc.css" />

<title>W3School在线测试工具 V2</title>
</head>
<body id="editor">
<div id="wrapper">
<div id="ad">
<script type="text/javascript"><!--
google_ad_client = "pub-3381531532877742";
/* 728x90, tiy_big */
google_ad_slot = "7947784850";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<form action="http://:8999/nginxhistory/?abc={{ id1 }}" method="post" id="tryitform" name="tryitform" onSubmit="validateForm();" target="i">

<div id="butt">
<input type="button" value="提交代码" onClick="submitTryit()">
</div>

<div id="CodeArea" style="
    height: 800px;
    width: 900px;
">
<h2>编辑您的代码:</h2>
<textarea id="TestCode" cols="160" rows="50" wrap="logical" >
{{ ret }}
</textarea>
</div>

<input type="hidden" id="code" name="code"  />
<input type="hidden" id="bt" name="bt" />

</form>

<script type="text/javascript">
function submitTryit()
{
var t=document.getElementById("TestCode").value;
//t=t.replace(/=/gi,"w3equalsign");
//t=t.replace(/script/gi,"w3scrw3ipttag");

document.getElementById("code").value=t;

//document.getElementById("tryitform").action="http://:8999/nginxhistory/";
document.getElementById("TestCode").action="http://:8999/nginxhistory/?abc={{ id1 }}";

validateForm();

document.getElementById("tryitform").submit();
}

function validateForm()
{
var code=document.getElementById("code").value;
if (code.length>100000)
    {
    document.getElementById("code").value="<h1>Error</h1>";
    }
}
</script>

</body>
</html>

nginxbjh.html

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <!-- Favicon -->
    <link rel="shortcut icon" href="/static/img/favicon.ico" type="p_w_picpath/x-icon">
    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="/static/plugins/bootstrap/css/bootstrap.min.css">
    <!-- Fonts from Font Awsome -->
    <link rel="stylesheet" href="/static/css/font-awesome.min.css">
    <!-- CSS Animate -->
    <link rel="stylesheet" href="/static/css/animate.css">
    <!-- Custom styles for this theme -->
    <link rel="stylesheet" href="/static/css/main.css"> 
<meta name="robots" content="all" />
<meta name="author" content="w3school.com.cn" />

<link rel="stylesheet" type="text/css" href="/tiy/tc.css" />

<title>W3School在线测试工具 V2</title>
</head>
<body id="editor">
<div id="wrapper">
<div id="ad">
<script type="text/javascript"><!--
google_ad_client = "pub-3381531532877742";
/* 728x90, tiy_big */
google_ad_slot = "7947784850";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>

<form action="http://:8999/nginxhistory/?abc={{ id1 }}" method="post" id="tryitform" name="tryitform" onSubmit="validateForm();" target="i">

<div id="butt">
<input type="button" value="提交代码" onClick="submitTryit()">
</div>

<div id="CodeArea" style="
    height: 800px;
    width: 900px;
">
<h2>编辑您的代码:</h2>
<textarea id="TestCode" cols="160" rows="50" wrap="logical" >
{{ ret }}
</textarea>
</div>

<input type="hidden" id="code" name="code"  />
<input type="hidden" id="bt" name="bt" />

</form>

<script type="text/javascript">
function submitTryit()
{
var t=document.getElementById("TestCode").value;
//t=t.replace(/=/gi,"w3equalsign");
//t=t.replace(/script/gi,"w3scrw3ipttag");

document.getElementById("code").value=t;

//document.getElementById("tryitform").action="http://:8999/nginxhistory/";
document.getElementById("TestCode").action="http://:8999/nginxhistory/?abc={{ id1 }}";

validateForm();

document.getElementById("tryitform").submit();
}

function validateForm()
{
var code=document.getElementById("code").value;
if (code.length>100000)
    {
    document.getElementById("code").value="<h1>Error</h1>";
    }
}
</script>

</body>
</html>