标签:url 一点 font nts 支持 use 静态 center ccf
环境:
win7系统
Python2.7
眼下项目中须要加入一个激活码功能,打算单独弄一个httpserver来写。
由于之前的游戏中已经有了一套完整的激活码生成工具和验证httpserver,所以直接拿过来使用了。
都是用Python写的,httpserver用到了Python微框架Bottle。
Bottle是一个很精致的WSGI框架。它提供了 Python Web开发中须要的基本支持:
URL路由。
from bottle import route, run
@route(‘/hello‘) #将路由/hello关联到函数hello()
def hello():
return "Hello World!"
run(host=‘localhost‘, port=8080, debug=True)
from bottle import Bottle, route, run, template, error
app = Bottle()
@app.route(‘/hello‘)
def hello():
return "Hello World!"
@app.route(‘/‘) # 缺省路由
@app.route(‘/hello/<name>‘) # hello下的全部路由
def greet(name=‘Stranger‘):
return template(‘Hello {{name}}, how are you?‘, name=name)
@app.error(404)
def error404(error):
return ‘Nothing here, sorry‘
run(app, host=‘localhost‘, port=8080)@route(‘/static/<filepath:path>‘)
def server_static(filepath):
return static_file(filepath, root=‘/path/to/your/static/files‘)标签:url 一点 font nts 支持 use 静态 center ccf
原文地址:http://www.cnblogs.com/blfbuaa/p/6915062.html