forked from sublimehq/packagecontrol.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.py
More file actions
executable file
·48 lines (31 loc) · 1.38 KB
/
dev.py
File metadata and controls
executable file
·48 lines (31 loc) · 1.38 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
#!/usr/bin/env python
import os.path as path
import bottle
import app.env
app.env.name = 'dev'
import app.controllers
from app.lib.json_api_middleware import JsonApiMiddleware
from app.lib.trailing_slash_filter import remove_trailing_slash
from app.lib.version_header import add_version
# For development, serve static files also
app_root = path.join(path.dirname(__file__), 'app')
public_root = path.join(path.dirname(__file__), 'public')
readme_img_root = path.join(path.dirname(__file__), 'readmes', 'img')
@bottle.route('/<folder:re:(css|img|js|font)>/<filename>')
def server_static(folder, filename):
return bottle.static_file(filename, root="%s/%s" % (public_root, folder))
@bottle.route('/readmes/img/<filename>')
def serve_readme_img(filename):
return bottle.static_file(filename, root=readme_img_root)
@bottle.route('/<filename:re:.*\.html$>')
def server_html(filename):
response = bottle.static_file(filename, root="%s/html" % app_root)
# By default the static_file handler creates a new response, so we can't
# just use the default hook, since it grabs bottle.response
return add_version(response)
@bottle.route('/favicon.ico')
def server_fav():
return bottle.static_file('favicon.ico', root=public_root)
sublime_app = bottle.app()
sublime_app = JsonApiMiddleware(sublime_app)
bottle.run(app=sublime_app, host='0.0.0.0', port=9000, debug=True, reloader=True)