main.py

__author__ = 'Liao'

import web
import time urls = (
'/gettime','gettime',
'/(.*)', 'hello'
)
app = web.application(urls, globals()) class gettime:
def GET(self):
asctime=time.asctime()
print asctime
return asctime
def POST(self):
return self.GET() class hello:
def GET(self, name):
if not name:
name = 'World'
return 'Hello, ' + name + '!' if __name__ == "__main__":
app.run()

ajaxrawjs.html

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>this is a ajax rawjs page </h1>
<p>static files must be put in <font color="red" ><b> static</b></font> directory in webpy !</p> <form name="myForm">
用户: <input type="text" name="username" onkeyup="ajaxFunction();" />
时间: <input type="text" name="time" />
</form> <script type="text/javascript">
function ajaxFunction()
{
var xmlHttp; try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{ // Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{ try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("您的浏览器不支持AJAX!");
return false;
}
}
} xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
document.myForm.time.value=xmlHttp.responseText;
}
}
xmlHttp.open("GET","/gettime",true);
xmlHttp.send(null); }
</script> </body>
</html>

ajaxjquery.html

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title> <!-- jquery下载地址:http://jquery.com/download/ -->
<script src="jquery-1.12.1.min.js"></script>
</head>
<body>
<h1>this is a ajax jquery page </h1>
<p>static files must be put in <font color="red" ><b> static</b></font> directory in webpy !</p> <form name="myForm">
用户: <input type="text" name="username" onkeyup="ajaxFunction();" />
时间: <input type="text" id="time123" name="time" />
</form> <script type="text/javascript">
function ajaxFunction()
{
// alert("bbb");
// alert("bbb "+"cc");
// alert("bbb "+ $("input[name='username']").val() );
// $("input[name='time']").val( $("input[name='username']").val() );
// $("#time123").val( $("input[name='username']").val() ); htmlobj=$.ajax({url:"/gettime",async:false,method:"GET"});
$("#time123").val(htmlobj.responseText);
}
</script> </body>
</html>

python web框架企业实战具体解释(第六期)\第三课时-ajax&amp;jquery&amp;webpy的更多相关文章

  1. python web框架介绍对比

    Django Python框架虽然说是百花齐放,但仍然有那么一家是最大的,它就是Django.要说Django是Python框架里最好的,有人同意也有人 坚决反对,但说Django的文档最完善.市场占 ...

  2. python三大web框架Django,Flask,Flask,Python几种主流框架,13个Python web框架比较,2018年Python web五大主流框架

    Python几种主流框架 从GitHub中整理出的15个最受欢迎的Python开源框架.这些框架包括事件I/O,OLAP,Web开发,高性能网络通信,测试,爬虫等. Django: Python We ...

  3. Python Web框架Tornado的异步处理代码演示样例

    1. What is Tornado Tornado是一个轻量级但高性能的Python web框架,与还有一个流行的Python web框架Django相比.tornado不提供操作数据库的ORM接口 ...

  4. Django,Flask,Tornado三大框架对比,Python几种主流框架,13个Python web框架比较,2018年Python web五大主流框架

    Django 与 Tornado 各自的优缺点Django优点: 大和全(重量级框架)自带orm,template,view 需要的功能也可以去找第三方的app注重高效开发全自动化的管理后台(只需要使 ...

  5. Python Web框架本质——Python Web开发系列一

    前言:了解一件事情本质的那一瞬间总能让我获得巨大的愉悦感,希望这篇文章也能帮助到您. 目的:本文主要简单介绍Web开发中三大基本功能:Socket实现.路由系统.模板引擎渲染. 进入正题. 一. 基础 ...

  6. 零基础小白必看篇:从0到1构建Python Web框架

    造轮子是最好的一种学习方式,本文尝试从0开始造个Python Web框架的轮子,我称它为ToyWebF. 本文操作环境为:MacOS,文中涉及的命令,请根据自己的系统进行替换. ToyWebF的简单特 ...

  7. python web框架——扩展Django&tornado

    一 Django自定义分页 目的:自定义分页功能,并把它写成模块(注意其中涉及到的python基础知识) models.py文件 # Create your models here. class Us ...

  8. 异步非阻塞IO的Python Web框架--Tornado

    Tornado的全称是Torado Web Server,从名字上就可知它可用作Web服务器,但同时它也是一个Python Web的开发框架.最初是在FriendFeed公司的网站上使用,FaceBo ...

  9. 微型 Python Web 框架 Bottle - Heroin blog

    微型 Python Web 框架 Bottle - Heroin blog 微型 Python Web 框架 Bottle

随机推荐

  1. timer event

    /* linux/kernel/time/jiffies.c*/ static cycle_t jiffies_read(struct clocksource *cs) { return (cycle ...

  2. fork()函数,一次调用,两次返回

    参考自:http://blog.csdn.net/dog_in_yellow/archive/2008/01/13/2041079.aspx 以前一直迷惑,什么叫一次调用,两次返回.通过上网搜索,终于 ...

  3. C++中 #ifdef 和#endif的作用

    一般情况下,源程序中所有的行都参加编译.但是有时希望对其中一部分内容只在满足一定条件才进行编译,也就是对一部分内容指定编译的条件,这就是"条件编译".有时,希望当满足某条件时对一组 ...

  4. C++ 字符串分割,并把子字符串转换成int型整数

    主要涉及到string类的两个函数find和substr: find()函数的用法: 原型:size_t find ( const string& str, size_t pos = 0 ) ...

  5. DocView mode 0 -- 介绍

          DocView mode,可作为主模式也可以作为minor mode,可以用来阅读DVI(ps后缀),PDF,OpenDocument(libreoffice文档),微软的doc.支持截取 ...

  6. 一、harbor部署之centos7的基本配置

    1 最小安装centos7 ...安装省略... centos7最小化安装后没ifconfig命令,用 ip addr 命令查看网络信息. 2 配置网络 1.cd /etc/sysconfig/net ...

  7. 关于面试总结-SQL经典面试题

    关于面试总结6-SQL经典面试题 前言 用一条SQL 语句查询xuesheng表每门课都大于80 分的学生姓名,这个是面试考sql的一个非常经典的面试题 having和not in 查询 xueshe ...

  8. HDU-4849 Wow! Such City!,最短路!

    Wow! Such City!    题意:题面很难理解,幸亏给出了提示,敲了一发板子过了.给出x数组y数组和z数组的求法,并给出x.y的前几项,然后直接利用所给条件构造出z数组再构造出C数组即可,C ...

  9. BZOJ3130 [Sdoi2013]费用流 【网络流 + 二分】

    题目 Alice和Bob在图论课程上学习了最大流和最小费用最大流的相关知识. 最大流问题:给定一张有向图表示运输网络,一个源点S和一个汇点T,每条边都有最大流量.一个合法的网络流方案必须满足:(1)每 ...

  10. bzoj1734 [Usaco2005 feb]Aggressive cows 愤怒的牛 二分答案

    [Usaco2005 feb]Aggressive cows 愤怒的牛 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 407  Solved: 325[S ...