-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from gxitm/master
添加本地转码api
- Loading branch information
Showing
4 changed files
with
186 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
# vim: set et sw=4 ts=4 sts=4 ff=unix fenc=utf8: | ||
# Author: Binux<[email protected]> | ||
# http://binux.me | ||
# Created on 2014-08-08 21:06:02 | ||
|
||
import time | ||
from base import * | ||
|
||
import requests | ||
import re | ||
|
||
class AboutHandler(BaseHandler): | ||
@tornado.web.addslash | ||
def get(self): | ||
user = self.current_user | ||
tpls = [] | ||
url = "https://github.com/qiandao-today/templates/blob/master/about.md" | ||
|
||
res = requests.get(url, verify=False) | ||
if (res.status_code == 200): | ||
content = res.content.decode(res.encoding, 'replace') | ||
About_content = re.findall(r"<article([\w\W]+?)</article", content)[0] | ||
tpls_temp = re.findall(r"tr>([\w\W]+?)</tr", About_content) | ||
|
||
for cnt in range(1, len(tpls_temp)): | ||
tpl_temp = re.findall(r"center\">(.+?)</td", tpls_temp[cnt]) | ||
apiurl = re.findall(r"href=\"(.+?)\"", tpl_temp[1])[0] | ||
example = re.findall(r">(.+?)<", tpl_temp[5])[0] | ||
|
||
tpls.append ({ | ||
"api":tpl_temp[0], | ||
"url":apiurl, | ||
"vars":tpl_temp[2], | ||
"varsreq":tpl_temp[3], | ||
"comments":tpl_temp[4], | ||
"examples":example | ||
}) | ||
|
||
self.render('about.html', tpls=tpls) | ||
|
||
handlers = [ | ||
('/about/?', AboutHandler), | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block title %}关于{% endblock %} | ||
|
||
{% block head %} | ||
{{ super() }} | ||
<link href="{{ static_url('my.css') }}" rel="stylesheet" type="text/css"> | ||
{% endblock %} | ||
|
||
{% block body %} | ||
{{ utils.header(current_user) }} | ||
|
||
<section class="tpl"> | ||
<div class="container"> | ||
<h2> | ||
常用Api | ||
</h2> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th style="text-align:center">api</th> | ||
<th style="text-align:center">地址</th> | ||
<th style="text-align:center">参数</th> | ||
<th style="text-align:center">参数是否必须</th> | ||
<th style="text-align:center">说明</th> | ||
<th style="text-align:center">用例</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for tpl in tpls %} | ||
<tr> | ||
<td style="text-align:center">{{ tpl.api }}</td> | ||
<td style="text-align:center">{{ tpl.url }}</td> | ||
<td style="text-align:center">{{ tpl.vars | safe }}</td> | ||
<td style="text-align:center">{{ tpl.varsreq }}</td> | ||
<td style="text-align:center">{{ tpl.comments | safe }}</td> | ||
<td style="text-align:center">{{ tpl.examples | safe }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<h2> | ||
常用参数及过滤器 | ||
</h2> | ||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th style="text-align:center">参数</th> | ||
<th style="text-align:center">说明</th> | ||
</tr> | ||
</thead> | ||
</table> | ||
</div> | ||
</section> | ||
|
||
<script> | ||
$(function() { | ||
$('[data-toggle=popover]').popover({ | ||
trigger: 'hover' | ||
}); | ||
}) | ||
</script> | ||
|
||
{{ utils.modal_load() }} | ||
{{ utils.apost() }} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters