Skip to content
Snippets Groups Projects
Commit eb397cac authored by Aydin, Mehmet Can (PG/T - Comp Sci & Elec Eng)'s avatar Aydin, Mehmet Can (PG/T - Comp Sci & Elec Eng)
Browse files

docker is working properly, runsh file is added to the folder which runs all dockers consecutively

parent f6d26e48
No related branches found
No related tags found
1 merge request!31docker is working properly, runsh file is added to the folder which runs all dockers consecutively
CONFIGURATION_SETUP="config.DevelopmentConfig"
CONFIGURATION_SETUP="config.ProductionConfig"
......@@ -6,7 +6,6 @@ from flask_login import LoginManager
from flask_ckeditor import CKEditor
login_manager = LoginManager()
UPLOAD_FOLDER = os.path.join('static', 'images')
app = None
def create_app():
......@@ -17,7 +16,6 @@ def create_app():
return app
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
# Load environment variables
load_dotenv()
......
frontend/application/static/images/1984a21b73b88524.jpeg

3.52 KiB

frontend/application/static/images/users/e6be63b80a5b9efe.jpeg

3.52 KiB

......@@ -35,4 +35,4 @@ urllib3==1.26.15
visitor==0.1.3
Werkzeug==2.2.3
WTForms==3.0.1
Pillow==9.0.1
CONFIGURATION_SETUP="config.DevelopmentConfig"
CONFIGURATION_SETUP="config.ProductionConfig"
......@@ -16,4 +16,4 @@ RUN pip3 install -r requirements.txt
COPY . /post-service
CMD [ "./wait-for-it.sh", "user-db:3306", "--timeout=0" ,"--","python3", "run.py"]
CMD [ "./wait-for-it.sh", "post-db:3306", "--timeout=0" ,"--","python3", "run.py"]
......@@ -7,8 +7,15 @@ from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
app = None
def create_app():
global app
if app is not None:
return app
app = Flask(__name__)
# Load environment variables
......
# application/post_api/api/UserClient.py
import requests
from application import app
class UserClient:
user_service = app.config['USER_SERVICE']
@staticmethod
def get_username(user_id):
url='http://localhost:5001/api/' + str(user_id) + '/username'
url='http://'+ UserClient.user_service +'/api/' + str(user_id) + '/username'
response = requests.request(method="GET", url=url)
response = response.json()
......@@ -19,7 +23,8 @@ class UserClient:
headers = {
'Authorization': api_key
}
response = requests.request(method="GET", url='http://localhost:5001/api/user', headers=headers)
url='http://'+ UserClient.user_service +'/api/user'
response = requests.request(method="GET", url=url, headers=headers)
if response.status_code == 401:
return False
user = response.json()
......
......@@ -15,6 +15,7 @@ class Config:
class DevelopmentConfig(Config):
ENV = "development"
DEBUG = True
USER_SERVICE = "localhost:5001"
SQLALCHEMY_DATABASE_URI = 'sqlite:///posts-service.db'
SQLALCHEMY_ECHO = True
......@@ -22,5 +23,6 @@ class DevelopmentConfig(Config):
class ProductionConfig(Config):
ENV = "production"
DEBUG = True
USER_SERVICE = "user-service:5001"
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://post-service:pass1234@post-db:3306/post'
SQLALCHEMY_ECHO = False
run.sh 0 → 100644
#!/bin/bash
sudo apt-get install dbus-x11
# user-service'i başlat
cd user-service
docker-compose build
gnome-terminal -- docker-compose up
cd ..
# post-service'i başlat
cd post-service
docker-compose build
gnome-terminal -- docker-compose up
cd ..
# frontend'i başlat
cd frontend
docker-compose build
gnome-terminal -- docker-compose up
cd ..
\ No newline at end of file
CONFIGURATION_SETUP="config.DevelopmentConfig"
CONFIGURATION_SETUP="config.ProductionConfig"
......@@ -8,7 +8,7 @@ class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(255), unique=True, nullable=False)
phone_number = db.Column(db.String(255), unique=False, nullable=True)
uni_number = db.Column(db.Integer, unique=False, nullable=True)
uni_number = db.Column(db.String(255), unique=False, nullable=True)
user_role = db.Column(db.String(255), unique=False, nullable=False)
first_name = db.Column(db.String(255), unique=False, nullable=False)
last_name = db.Column(db.String(255), unique=False, nullable=False)
......
......@@ -53,7 +53,6 @@ def get_users():
response = jsonify(data)
return response
@user_api_blueprint.route('/api/user/create', methods=['POST'])
def post_register():
first_name = request.form['first_name']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment