-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from kakakakakku/v2.0.1
Added v2.0.1
- Loading branch information
Showing
6 changed files
with
98 additions
and
0 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
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,5 @@ | ||
FROM python:3.4-alpine | ||
ADD . /code | ||
WORKDIR /code | ||
RUN pip install -r requirements.txt | ||
CMD ["python", "app.py"] |
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,29 @@ | ||
import time | ||
|
||
import redis | ||
from flask import Flask | ||
|
||
|
||
app = Flask(__name__) | ||
cache = redis.Redis(host='redis', port=6379) | ||
|
||
|
||
def get_hit_count(): | ||
retries = 5 | ||
while True: | ||
try: | ||
return cache.incr('hits') | ||
except redis.exceptions.ConnectionError as exc: | ||
if retries == 0: | ||
raise exc | ||
retries -= 1 | ||
time.sleep(0.5) | ||
|
||
|
||
@app.route('/') | ||
def hello(): | ||
count = get_hit_count() | ||
return 'Hello World! I have been seen {} times.\n'.format(count) | ||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", debug=True) |
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,8 @@ | ||
version: '3' | ||
services: | ||
web: | ||
build: . | ||
ports: | ||
- "5000:5000" | ||
redis: | ||
image: "redis:alpine" |
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,2 @@ | ||
flask | ||
redis |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.