forked from hmason/gitmarks_hm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitmark_web.py
46 lines (33 loc) · 1.05 KB
/
gitmark_web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Web frontend to gitmarks for use as a bookmarklet.
"""
import bottle
bottle.debug(False)
from bottle import route, run, request, response, template
from gitmark import gitMark
import settings
@route("/")
def index():
return template("index", port = settings.GITMARKS_WEB_PORT)
@route("/new")
def new():
url = request.GET.get('url')
return template("new", url=url, tags=None, message=None, error=None)
@route("/create", method = "POST")
def create():
url = request.forms.get('url', '').strip()
tags = request.forms.get('tags', '').strip()
message = request.forms.get('message', '').strip()
push = request.forms.get('nopush', True)
if push == '1':
push = False
if not url:
return template("new", url=url, tags=tags, message=message, error="URL is required.")
options = {}
options['tags'] = tags
options['push'] = push
options['msg'] = message
args = [url]
g = gitMark(options, args)
return template("create")
run(host="localhost", port=settings.GITMARKS_WEB_PORT, reloader=False)