Misc usability fixes

1. Added binding address in config
2. Added missing dependency sqlalchemy
3. Added permanent redirect to index.html
This commit is contained in:
2020-06-06 23:22:35 +05:30
parent 85fd18bfb2
commit 38a4e0839c
4 changed files with 10 additions and 1 deletions
+1
View File
@@ -1,2 +1,3 @@
DB_CONNECTION=postgresql://postgres@localhost/postgres DB_CONNECTION=postgresql://postgres@localhost/postgres
BIND_ADDRESS=127.0.0.1:8000
+1
View File
@@ -1,2 +1,3 @@
falcon==1.4.1 falcon==1.4.1
gunicorn==19.9.0 gunicorn==19.9.0
sqlalchemy
+2 -1
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
[ -f ./config ] && . ./config && export DB_CONNECTION [ -f ./config ] && . ./config && export DB_CONNECTION
gunicorn server:api bindAddress=${BIND_ADDRESS:-'127.0.0.1:8000'}
gunicorn server:api -b $bindAddress "$@"
+6
View File
@@ -22,6 +22,12 @@ class QResource:
resp.set_header('content-type', 'application/json; charset=UTF-8') resp.set_header('content-type', 'application/json; charset=UTF-8')
resp.body = json.dumps( data, default=str ) resp.body = json.dumps( data, default=str )
class RedirectingResource:
def on_get(self, req, resp):
raise falcon.HTTPMovedPermanently('/index.html')
api = falcon.API() api = falcon.API()
api.add_route('/', RedirectingResource())
api.add_static_route('/', os.path.dirname(os.path.realpath(__file__)) + '/static' ) api.add_static_route('/', os.path.dirname(os.path.realpath(__file__)) + '/static' )
api.add_route('/api/data', QResource()) api.add_route('/api/data', QResource())