-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from hackforla/async_backend
Added asynchronicity to the backend and boilerplate services
- Loading branch information
Showing
7 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,5 @@ package-lock.json | |
config.js | ||
.env | ||
settings.cfg | ||
|
||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class frequency(object): | ||
def __init__(self): | ||
pass | ||
|
||
def hello_world(self): | ||
return {'response':'hello from frequency service'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
REDACTED=REDACTED | ||
DEBUG=True | ||
HOST="0.0.0.0" | ||
PORT="5000" | ||
REDACTED = "REDACTED" |