forked from textmate/python.tmbundle
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNew web_py.tmSnippet
More file actions
69 lines (57 loc) · 1.78 KB
/
New web_py.tmSnippet
File metadata and controls
69 lines (57 loc) · 1.78 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<string>#!/usr/bin/env python
# coding: utf-8
import os
import sys
import web
import daemon
import gflags
import logging
from pygaga.helpers.logger import log_init
from pygaga.helpers.webutils import file_env, render_to_string, render_html
logger = logging.getLogger('WebLogger')
FLAGS = gflags.FLAGS
file_path = os.path.split(os.path.abspath(__file__))[0]
ENV = file_env(file_path)
urls = (
'/', 'home',
)
def my_filter(input):
return input
ENV.filters['my_filter'] = my_filter
class home:
def GET(self):
return 'test'
if __name__ == "__main__":
# usage: ${prog} ip:port --daemon --stderr ...
gflags.DEFINE_boolean('daemon', False, "is start in daemon mode?")
gflags.DEFINE_boolean('webdebug', False, "is web.py debug")
gflags.DEFINE_boolean('reload', False, "is web.py reload app")
backup_args = []
backup_args.extend(sys.argv)
sys.argv = [sys.argv[0],] + sys.argv[2:]
log_init('WebLogger', "sqlalchemy.*")
sys.argv = backup_args[:2]
web.config.debug = FLAGS.webdebug
if len(sys.argv) == 1:
web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
if FLAGS.daemon:
daemon.daemonize(os.path.join(file_path, 'web.pid'))
#render = web.template.render('templates/', base='layout')
app = web.application(urls, globals(), autoreload=FLAGS.reload)
app.run()
</string>
<key>name</key>
<string>new web.py template</string>
<key>scope</key>
<string>source.python</string>
<key>tabTrigger</key>
<string>web</string>
<key>uuid</key>
<string>1B403321-EC35-49D6-8756-F80C630150B4</string>
</dict>
</plist>