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

Practice 6 Submit NguyenQuangNhatTruong #151

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1c61939
Add files via upload
truong022001 May 26, 2022
cd792e6
Update README.md
truong022001 May 26, 2022
49cfc07
Update README.md
truong022001 May 26, 2022
66d9cfe
Add files via upload
truong022001 Jun 5, 2022
6df4692
Add files via upload
truong022001 Jun 5, 2022
886c486
Create .keep
truong022001 Jun 5, 2022
2572c20
Add files via upload
truong022001 Jun 5, 2022
722ea83
Delete Practice-3/Project directory
truong022001 Jun 5, 2022
2ddaf29
Delete Practice-3/imgs directory
truong022001 Jun 5, 2022
9a105fe
Delete README.md
truong022001 Jun 5, 2022
37e7092
Create .keep
truong022001 Jun 5, 2022
c9176d0
Add files via upload
truong022001 Jun 5, 2022
1953d9b
Create .keep
truong022001 Jun 17, 2022
3e0730e
Add files via upload
truong022001 Jun 17, 2022
20ebcff
Delete Practice-4/NguyenQuangNhatTruong/imgs directory
truong022001 Jun 17, 2022
3161006
Delete README.md
truong022001 Jun 17, 2022
79b25a2
Add files via upload
truong022001 Jun 17, 2022
b100afb
Merge pull request #1 from truong022001/practice4-1
truong022001 Jun 17, 2022
7fdeb9d
Delete Practice-2/NguyenQuangNhatTruong directory
truong022001 Jun 17, 2022
89fe3c0
Delete Practice-2/imgs directory
truong022001 Jun 17, 2022
fe4565a
Delete README.md
truong022001 Jun 17, 2022
9f94a72
Create .keep
truong022001 Jun 17, 2022
95927ce
Merge pull request #2 from truong022001/practice2
truong022001 Jun 17, 2022
2501a20
Create .keep
truong022001 Jun 19, 2022
277a19c
Merge pull request #3 from truong022001/practice-5
truong022001 Jun 19, 2022
06d8b00
Create .keep
truong022001 Jun 24, 2022
da07358
Add files via upload
truong022001 Jun 24, 2022
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
1 change: 1 addition & 0 deletions Practice-2/NguyenQuangNhatTruong/.keep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions Practice-3/NguyenQuangNhatTruong/.keep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

11 changes: 11 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.9
WORKDIR /code
COPY requirements.txt requirements.txt

RUN pip install --upgrade pip \
pip install --no-cache-dir -r requirements.txt
COPY app.py .
ENV FLASK_APP=app
ENV FLASK_RUN_HOST=0.0.0.0
EXPOSE 5000
CMD ["flask","run"]
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/backend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from flask import Flask
from flask import request
from pymongo import MongoClient
from flask_cors import CORS
from bson.json_util import dumps

client = MongoClient(
host='mongo',
port=27017,
username='myUserAdmin',
password='abc123',
authSource="admin"
)
db = client["datasource"]

app = Flask(__name__)
CORS(app)

@app.route("/get_all", methods = ['GET'])
def get_all():
try:
users = db["member"].find()
return dumps(users)
except:
return "Error"

if __name__ == "__main__":
app.run(debug=True, host='0.0.0.0', port=5000)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flask==2.1.2
flask-cors
pymongo==4.1.1
36 changes: 36 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: '3'
networks:
web-server:
name: web-server
services:
frontend:
build: frontend
ports:
- 3000:80
depends_on:
- backend
networks:
- web-server

backend:
build: backend
hostname: localhost
ports:
- 5000:5000
depends_on:
- mongo
networks:
- web-server
mongo:
image: mongo:5.0
container_name: mongo
restart: unless-stopped
command: mongod --auth
environment:
MONGO_INITDB_ROOT_USERNAME: myUserAdmin
MONGO_INITDB_ROOT_PASSWORD: abc123
MONGO_INIT_DATABASE: datasource
ports:
- 27017:27017
networks:
- web-server
5 changes: 5 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx:1.22.0-alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/sites-enabled/default
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Stage 1
FROM node:14.16-alpine3.10 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
70 changes: 70 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.

The page will reload when you make changes.\
You may also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can't go back!**

If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.

You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `npm run build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
11 changes: 11 additions & 0 deletions Practice-3/NguyenQuangNhatTruong/Project/frontend/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
server {
listen 80;
server_name localhost;
location / {

root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html;
}

}
Loading