Add a WSGI file

This commit is contained in:
Lucas Verney 2018-06-26 15:55:52 +02:00
parent ad6cc13681
commit 6fad8b7fac
3 changed files with 24 additions and 1 deletions

View File

@ -58,6 +58,11 @@ adapt its behavior:
means `localhost` only). means `localhost` only).
* `PORT=` to specify the port to listen on (defaults to `8081`). * `PORT=` to specify the port to listen on (defaults to `8081`).
### Serving
You can use the `wsgi.py` script at the root of the git repository to serve
the server side part.
## Contributing ## Contributing

View File

@ -11,7 +11,7 @@ from server.jsonapi import DateAwareJSONEncoder
from server.models import db, Report from server.models import db, Report
if __name__ == "__main__": def init():
db.connect() db.connect()
db.create_tables([Report]) db.create_tables([Report])
@ -22,6 +22,11 @@ if __name__ == "__main__":
json_dumps=functools.partial(json.dumps, cls=DateAwareJSONEncoder) json_dumps=functools.partial(json.dumps, cls=DateAwareJSONEncoder)
) )
) )
if __name__ == "__main__":
init()
bottle.run( bottle.run(
host=os.environ.get('HOST', '127.0.0.1'), host=os.environ.get('HOST', '127.0.0.1'),
port=int(os.environ.get('PORT', '8081')) port=int(os.environ.get('PORT', '8081'))

13
wsgi.py Normal file
View File

@ -0,0 +1,13 @@
# coding: utf-8
"""
Expose a WSGI-compatible application to serve with a webserver.
"""
from __future__ import absolute_import, print_function, unicode_literals
import bottle
from server.__main__ import init
init()
application = app = bottle.default_app()