Skip to content

Commit

Permalink
run server from cli #48
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Fekete committed Oct 16, 2019
1 parent ca7fc20 commit 48ff9b5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion abcd/frontends/commandline/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,19 @@ def execute(*, db, query, yes, python_code, **kwargs):

@check_readonly
def server(*, abcd_url, url, api_only, **kwargs):
from urllib.parse import urlparse
from abcd.server.app import create_app

logger.info("SERVER - abcd: {}, url: {}, api_only:{}".format(abcd_url, url, api_only))
exit(0)

if api_only:
print("Not implemented yet!")
exit(1)

o = urlparse(url)

app = create_app(abcd_url)
app.run(host=o.hostname, port=o.port)


class Formater(object):
Expand Down
2 changes: 1 addition & 1 deletion abcd/frontends/commandline/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
server.set_defaults(callback_func=commands.server)
server.add_argument('abcd_url', help='Url for abcd database.')
server.add_argument('--api-only', action='store_true', help='Running only the API.')
server.add_argument('-u', '--url', help='Url to run the server.', default='http://localhost:27017')
server.add_argument('-u', '--url', help='Url to run the server.', default='http://localhost:5000')


def main(args=None):
Expand Down
2 changes: 1 addition & 1 deletion abcd/server/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from abcd.server.app.views import index, database, api


def create_app():
def create_app(abcd_url=None):
# Define the WSGI application object
app = Flask(__name__)
app.logger.info('Creating an application')
Expand Down

0 comments on commit 48ff9b5

Please sign in to comment.