]> git.phdru.name Git - phdru.name/cgi-bin/blog-ru/search-tags.git/blob - search-tags.py
9bdfc8bb5bc1e4cd6711e6f7f4caad5fe5bc464c
[phdru.name/cgi-bin/blog-ru/search-tags.git] / search-tags.py
1 #! /usr/bin/env python
2 """Search tags CGI"""
3
4 __author__ = "Oleg Broytman <phd@phdru.name>"
5 __copyright__ = "Copyright (C) 2014 PhiloSoft Design"
6 __license__ = "GNU GPL"
7
8 import cgi
9 from ply.lex import LexError
10
11 from html.response import response
12 from parser.parser import parser
13
14 form = cgi.FieldStorage()
15 if not form.has_key('q'):
16     status = "400 Bad request"
17     title = "Error!"
18     body = "Required parameter is missing!"
19
20 else:
21     q = form['q'].value
22     try:
23         tree = parser.parse(q)
24     except LexError:
25         tree = None
26     if tree is None:
27         status = "400 Bad request"
28         title = "Error!"
29         body = "Bad query syntax!"
30
31 response(title, body, status)