python web代码转换成app_python_webApp

提高开发效率:当更改代码后,不重启服务器就能使用新效果

参考链接:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432339228196a8eb6fb8832b48b5aa0d740346536ead000

错误:

解决办法:

if __name__ == '__main__':

argv = sys.argv[1:]

if not argv:

print('Usage: ./pymonitor your-script.py')

exit(0)

if argv[0] != 'python3':

argv.insert(0, 'python3')

command = argv

path = os.path.abspath('.')

start_watch(path, None)

#替换为

if __name__ == '__main__':

argv = sys.argv[1:]

if not argv:

print('Usage: ./pymonitor your-script.py')

exit(0)

if argv[0] != 'python': # 这里用python不要用python3除非你的系统也是用python3 XX.PY来启动python程序的

argv.insert(0, 'python')

command = argv

path = os.path.abspath('.')

start_watch(path, None)

能在请求处理程序中返回html

参考链接:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432339095180ce91c53cdab841bfa9c342a297b886fe000

@get('/')

def index(request):

users = yield from User.findAll()#查询所有用户信息,用于接下来输出

return {

'__template__': 'test.html',

'users': users

}

#下面是所有的test.html的代码

Test users - Awesome Python Webapp

All users

{% for u in users %}

{{ u.name }} / {{ u.email }}

{% endfor %}

当用户在上面的输入框中键入字符时,会执行函数 "showHint()" 。该函数由 "onkeyup" 事件触发

参考链接:https://www.w3cschool.cn/ajax/ajax-asp-php.html

错误:

在用getElementById等寻找元素时,一定要让元素在

JavaScript 能够直接写入 HTML 输出流中:

您只能在 HTML 输出流中使用 document.write

如果您在文档已加载后使用它(比如在函数中),会覆盖整个文档。

x=document.getElementById("demo"); // 找到元素

x.innerHTML="Hello JavaScript!";

document.write("

This is a heading

");

document.write("

This is a paragraph.

");

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值