Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microservices #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Dockerfile
Empty file.
3 changes: 3 additions & 0 deletions db_connector/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mongo:latest
COPY . .
ENTRYPOINT []
2 changes: 1 addition & 1 deletion db_connector/config/keys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
mongoURI: "mongodb://lafb:lafb123@ds165632.mlab.com:63835/accounts"
mongoURI: "mongodb://23b18f2e852d:63835/accounts"
};

6 changes: 6 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3.7'
services:
mongo:
image: mongo
ports:
- "27017:27017"
6 changes: 6 additions & 0 deletions num_gen/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python
ARG FILE_VERSION=1
COPY . .
COPY num_gen${FILE_VERSION}.py app.py
RUN pip install flask
ENTRYPOINT ["python", "app.py"]
11 changes: 11 additions & 0 deletions num_gen/num_gen1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask, jsonify, make_response
from random import randint
num_gen = Flask(__name__)

@num_gen.route('/num_gen/', methods=['GET'])
def num_gen_method():
rand = randint(100000,999999)
return jsonify({"Random Number":rand})

if __name__ == '__main__':
num_gen.run(host='0.0.0.0', port=9018)
11 changes: 11 additions & 0 deletions num_gen/num_gen2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from flask import Flask, jsonify, make_response
from random import randint
num_gen = Flask(__name__)

@num_gen.route('/num_gen/', methods=['GET'])
def num_gen_method():
rand = randint(10000000,99999999)
return jsonify({"Random Number":rand})

if __name__ == '__main__':
num_gen.run(host='0.0.0.0', port=9018)
7 changes: 7 additions & 0 deletions prize_gen/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python
ARG FILE_VERSION=1
COPY . .
COPY prize_gen${FILE_VERSION}.py app.py
RUN pip install flask
RUN pip install requests
ENTRYPOINT ["python", "app.py"]
20 changes: 20 additions & 0 deletions prize_gen/prize_gen1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from flask import Flask, jsonify, make_response
import random
import requests
from random import randrange
prize_gen = Flask(__name__)


@prize_gen.route('/prize_gen/', methods=['GET'])
def reset(prob=25):
prize=50
percent = random.randrange(100)
if prob > percent:
request.get('http://52.142.204.121:9000/notify')
return jsonify({"User has won":prize})
else:
return "No prize for you"


if __name__ == '__main__':
prize_gen.run(host='0.0.0.0', port=5000)
20 changes: 20 additions & 0 deletions prize_gen/prize_gen2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from flask import Flask, jsonify, make_response
import random
import requests
from random import randrange
prize_gen = Flask(__name__)


@prize_gen.route('/prize_gen/', methods=['GET'])
def reset(prob=25):
prize=100
percent = random.randrange(100)
if prob > percent:
request.get('http://52.142.204.121:9000/notify')
return jsonify({"User has won":prize})
else:
return "No prize for you"


if __name__ == '__main__':
prize_gen.run(host='0.0.0.0', port=5000)
Empty file added server/Dockerfile
Empty file.
6 changes: 6 additions & 0 deletions text_gen/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python
ARG FILE_VERSION=1
COPY . .
COPY text_gen${FILE_VERSION}.py app.py
RUN pip install flask
ENTRYPOINT ["python", "app.py"]
14 changes: 14 additions & 0 deletions text_gen/text_gen1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from flask import Flask, jsonify, make_response
import random
import string

text_gen = Flask(__name__)


@text_gen.route('/text_gen/', methods=['GET'])
def text_gen_method():
rand = (''.join(random.choice(string.ascii_lowercase) for i in range(3)))
return jsonify({"Random string":rand})

if __name__ == '__main__':
text_gen.run(host='0.0.0.0', port=9017)
14 changes: 14 additions & 0 deletions text_gen/text_gen2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from flask import Flask, jsonify, make_response
import random
import string

text_gen = Flask(__name__)


@text_gen.route('/text_gen/', methods=['GET'])
def text_gen_method():
rand = (''.join(random.choice(string.ascii_uppercase) for i in range(2)))
return jsonify({"Random string":rand})

if __name__ == '__main__':
text_gen.run(host='0.0.0.0', port=9017)