-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (26 loc) · 882 Bytes
/
app.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
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from util.dbutil import db_connect
import logging
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
def run_server():
with Configurator() as config:
config.add_route('home', '/')
config.add_route('upload', '/upload')
config.add_route('get_tables', '/datasets')
config.add_route('get_headers', '/columns/{table_name}')
config.add_static_view(name='static', path='static')
config.include('pyramid_jinja2')
config.scan('views')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
server.serve_forever()
def main():
log.debug("Started")
print("Server started at http://localhost:6543/")
if not db_connect():
return
run_server()
if __name__ == '__main__':
main()