Explorar o código

flask and mongo in docker

Bernadette Elena Hammerle %!s(int64=4) %!d(string=hai) anos
pai
achega
40ca55f4dc
Modificáronse 4 ficheiros con 16 adicións e 3 borrados
  1. 2 0
      .gitignore
  2. 11 0
      Dockerfile
  3. 1 1
      src/App.js
  4. 2 2
      src/database_interface.py

+ 2 - 0
.gitignore

@@ -21,3 +21,5 @@
 npm-debug.log*
 yarn-debug.log*
 yarn-error.log*
+
+__pycache__

+ 11 - 0
Dockerfile

@@ -0,0 +1,11 @@
+FROM python:3.7-slim
+
+RUN pip install flask pymongo
+
+COPY src/database_interface.py / 
+
+#CMD env FLASK_APP=/database_interface.py flask run --host 0.0.0.0
+CMD python /database_interface.py
+
+EXPOSE 5000
+

+ 1 - 1
src/App.js

@@ -6,7 +6,7 @@ import Tables from './Tables';
 class App extends Component {
   constructor(props){
     super(props);
-    this.apiUrl = "http://localhost:5000";
+    this.apiUrl = "http://192.168.17.94:9876";
     this.name = null;
     this.state = {
       persons: []

+ 2 - 2
src/database_interface.py

@@ -5,7 +5,7 @@ import time
 
 app = Flask(__name__)
 
-client = MongoClient("192.168.17.90", 27017)
+client = MongoClient("sedatabase", 27017)
 db = client["react_database"]
 user = db["user"]
 location = db["location"]
@@ -84,4 +84,4 @@ if __name__=="__main__":
             }
         ])
     
-    app.run()
+    app.run(host='0.0.0.0')