|
| 1 | +#coding=utf-8 |
| 2 | +from bottle import static_file,route, run, post, request, redirect |
| 3 | +import os, makeweb, urllib,re,json,time |
| 4 | +Root = os.path.split(os.path.realpath(__file__))[0]+"/static/" |
| 5 | +Const = """ |
| 6 | +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 7 | +<html xmlns="http://www.w3.org/1999/xhtml"> |
| 8 | +<head> |
| 9 | +<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> |
| 10 | +<title>无标题文档</title> |
| 11 | +<link type="text/css" rel="stylesheet" href="./static/css.css" /> |
| 12 | +
|
| 13 | +</head> |
| 14 | +
|
| 15 | +<body> |
| 16 | +<div id="1"> |
| 17 | + <form id="form1" name="form1" method="post" action=""> |
| 18 | + <label>名字 |
| 19 | + <input id="name" type="text" name="textfield" tabindex="0" /> |
| 20 | + </label> |
| 21 | + <p> |
| 22 | + <label>评论 |
| 23 | + <textarea name="textarea" tabindex="1" style="height: 89px; width: 350px;"></textarea> |
| 24 | + </label> |
| 25 | + </p> |
| 26 | + <p> |
| 27 | + <label> |
| 28 | + <input id="Submit" type="submit" name="Submit" value="提交" /> |
| 29 | + </label> |
| 30 | + </p> |
| 31 | + </form> |
| 32 | +</div> |
| 33 | +<div> |
| 34 | + %s |
| 35 | +</div> |
| 36 | +</body> |
| 37 | +</html> |
| 38 | +
|
| 39 | +""" |
| 40 | +@route('/board') |
| 41 | +def index(): |
| 42 | + return Const%makeweb.Pack(makeweb.Stor_out()) |
| 43 | +@post('/board') |
| 44 | +def Accept(): |
| 45 | + Req = request.body.read() |
| 46 | + L = re.split("&",Req) |
| 47 | + M = {} |
| 48 | + for i in L: |
| 49 | + A = re.split("=",i) |
| 50 | + M[A[0]] = urllib.unquote(A[1]) |
| 51 | + New = {} |
| 52 | + New["Name"] = M["textfield"] |
| 53 | + New["Content"] = M["textarea"] |
| 54 | + makeweb.Stor_in(New) |
| 55 | + redirect('/board', 302) |
| 56 | + |
| 57 | +@route('/static/<filename>') |
| 58 | +def server_static(filename): |
| 59 | + return static_file(filename, root=Root) |
| 60 | +run(host='localhost',port=8080) |
0 commit comments