-
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.
#10 MongoDB connection successfully established and routes made more …
…legible
- Loading branch information
1 parent
79d583a
commit e53e3b9
Showing
4 changed files
with
28 additions
and
26 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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
version: '2' | ||
|
||
services: | ||
postgres: | ||
image: postgres:latest | ||
container_name: postgres_livereviews | ||
ports: | ||
- "5432:5432" | ||
|
||
mongodb: | ||
image: mongo:latest | ||
container_name: mongodb_livereviews | ||
ports: | ||
- "27017:27017" | ||
|
||
flask: | ||
restart: always | ||
build: . | ||
container_name: flask_livereviews | ||
ports: | ||
- 8000:8000 | ||
command: bash -c "sleep 2; python run.py" | ||
- "8000:8000" | ||
command: python run.py | ||
volumes: | ||
- .:/code | ||
links: | ||
- postgres:postgres_livereviews | ||
- mongodb:mongodb_livereviews | ||
|
||
networks: | ||
esnet: | ||
driver: bridge | ||
- postgres | ||
- mongodb |
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 |
---|---|---|
@@ -1,29 +1,25 @@ | ||
from models.database_setup import SQLAlchemyService | ||
|
||
from flask import Flask | ||
from api_cmds.routes import about_page | ||
from api_cmds.routes import index_page | ||
from api_cmds.routes import sign_up_page | ||
from api_cmds.routes import sign_out_page | ||
from api_cmds.routes import home_page | ||
from api_cmds.routes import login_page | ||
import pymongo | ||
|
||
from api_cmds.routes import routes | ||
|
||
app = Flask(__name__) | ||
app.secret_key = 'development-key' | ||
|
||
# Setup database connectivity | ||
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/location_based_service' | ||
# Setup connectivity with MongoDB | ||
mongo_client = pymongo.MongoClient('mongodb', 27017) | ||
|
||
# Setup database connectivity with Postgres | ||
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://postgres/location_based_service' | ||
SQLAlchemyService().instantiate_sql_alchemy() | ||
SQLAlchemyService().initialize_db(app) | ||
|
||
# Register blueprint for index and about pages | ||
app.register_blueprint(index_page) | ||
app.register_blueprint(about_page) | ||
app.register_blueprint(sign_up_page) | ||
app.register_blueprint(sign_out_page) | ||
app.register_blueprint(home_page) | ||
app.register_blueprint(login_page) | ||
|
||
app.secret_key = 'development-key' | ||
# Register all the url routes | ||
for route in routes: | ||
app.register_blueprint(route) | ||
|
||
if __name__ == "__main__": | ||
# Run flask app in debug bug on localhost | ||
app.run(host="0.0.0.0", port=8000, debug=True) | ||
app.run(host="0.0.0.0", port=8000, debug=True) |