diff --git a/.gitignore b/.gitignore index da1182e22..2ca305ab2 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ package-lock.json config.js .env settings.cfg + +__pycache__/ diff --git a/server/requirements.txt b/server/requirements.txt index a6d2d3aa7..5067ec730 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -1,6 +1,24 @@ +aiofiles==0.4.0 +certifi==2019.9.11 +chardet==3.0.4 Click==7.0 -Flask==1.1.1 +h11==0.8.1 +h2==3.1.1 +hpack==3.0.0 +httpcore==0.3.0 +httptools==0.0.13 +hyperframe==5.2.0 +idna==2.8 itsdangerous==1.1.0 Jinja2==2.10.3 MarkupSafe==1.1.1 +multidict==4.5.2 +requests==2.22.0 +requests-async==0.5.0 +rfc3986==1.3.2 +sanic==19.9.0 +ujson==1.35 +urllib3==1.25.7 +uvloop==0.14.0 +websockets==8.1 Werkzeug==0.16.0 diff --git a/server/src/app.py b/server/src/app.py index 89d5100a3..87595cf7e 100644 --- a/server/src/app.py +++ b/server/src/app.py @@ -1,18 +1,36 @@ import os -import json -from flask import Flask +from sanic import Sanic +from sanic.response import json +from services.time_to_close import time_to_close +from services.frequency import frequency -app = Flask(__name__) +app = Sanic(__name__) app.config.from_pyfile(os.path.join(os.getcwd(),'settings.cfg')) @app.route('/') -def index(): - return 'You hit the index' +async def index(request): + return json('You hit the index') + +@app.route('/timetoclose') +async def timetoclose(request): + ttc_worker = time_to_close() + # Insert time to close calculation here + return_data = ttc_worker.hello_world() + + return json(return_data) + +@app.route('/requestfrequency') +async def requestfrequency(request): + freq_worker = frequency() + # Insert frequency calculation here + return_data = freq_worker.hello_world() + + return json(return_data) @app.route('/sample-data') -def sample_route(): +async def sample_route(request): sample_dataset = {'cool_key':['value1', 'value2'], app.config['REDACTED']:app.config['REDACTED']} - return json.dumps(sample_dataset, indent=4) + return json(sample_dataset) if __name__ == '__main__': - app.run() + app.run(host=app.config['HOST'], port=app.config['PORT'], debug=app.config['DEBUG']) diff --git a/server/src/services/__init__.py b/server/src/services/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/server/src/services/frequency.py b/server/src/services/frequency.py new file mode 100644 index 000000000..d2deaa0f9 --- /dev/null +++ b/server/src/services/frequency.py @@ -0,0 +1,6 @@ +class frequency(object): + def __init__(self): + pass + + def hello_world(self): + return {'response':'hello from frequency service'} diff --git a/server/src/services/time_to_close.py b/server/src/services/time_to_close.py new file mode 100644 index 000000000..6bb6c7f7f --- /dev/null +++ b/server/src/services/time_to_close.py @@ -0,0 +1,6 @@ +class time_to_close(object): + def __init__(self): + pass + + def hello_world(self): + return {'response':'hello from time to close service'} diff --git a/server/src/settings.example.cfg b/server/src/settings.example.cfg index ba54c9f48..2c13b19e0 100644 --- a/server/src/settings.example.cfg +++ b/server/src/settings.example.cfg @@ -1 +1,4 @@ -REDACTED=REDACTED +DEBUG=True +HOST="0.0.0.0" +PORT="5000" +REDACTED = "REDACTED"