diff --git a/backend/.gitignore b/backend/.gitignore new file mode 100644 index 0000000..6df097b --- /dev/null +++ b/backend/.gitignore @@ -0,0 +1 @@ +/ven \ No newline at end of file diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..6bd73d4 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.12-alpine3.20 + +WORKDIR /app + +ENV FLASK_APP=main.py + +# Change app to development server +# ENV FLASK_APP=main.py + +COPY ./requirements.txt . + +RUN pip install -r ./requirements.txt + +COPY . . + +EXPOSE 5080 + +CMD ["python", "main.py"] diff --git a/backend/config.py b/backend/config.py new file mode 100644 index 0000000..aaf4a7d --- /dev/null +++ b/backend/config.py @@ -0,0 +1,29 @@ +from flask import Flask, jsonify +from flask_sqlalchemy import SQLAlchemy +from flask_cors import CORS +from dotenv import load_dotenv +import os +from flask_bcrypt import Bcrypt +import redis +from flask_session import Session + +app = Flask(__name__) +CORS(app, supports_credentials=True) +load_dotenv() +bcrypt = Bcrypt(app) + + +app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///mydatabase.db" +app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False +app.config["SQLALCHEMY_ECHO"] = True +app.config["SECRET_KEY"] = os.environ["SECRET_KEY"] +app.config["SESSION_TYPE"] = 'redis' +app.config["SESSION_PERMANENT"] = False +app.config["SESSION_USE_SIGNER"] = True +app.config["SESSION_REDIS"] = redis.from_url("redis://192.168.50.107:6379") +# app.config["REDIS_PASSWORD"] = os.environ["REDIS_PASSWORD"] + +db = SQLAlchemy(app) + +server_session = Session(app) +# 22:16 \ No newline at end of file diff --git a/backend/main.py b/backend/main.py new file mode 100644 index 0000000..73c4320 --- /dev/null +++ b/backend/main.py @@ -0,0 +1,21 @@ +from flask import Flask, render_template, request + + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/api/upload', methods=['POST']) +def upload(): + file = request.files['file'] + + # save the file + file.save(f'uploads/{file.filename}') + +# Main +if __name__ == "__main__": + # Initialize database connection + with app.app_context(): + db.create_all() + + app.run(debug=True, port=5080) \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..ed950a5 --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,7 @@ +flask +flask-sqlalchemy +flask-bcrypt +flask-cors +python-dotenv +flask-session +redis \ No newline at end of file diff --git a/backend/templates/index.html b/backend/templates/index.html new file mode 100644 index 0000000..9e73d78 --- /dev/null +++ b/backend/templates/index.html @@ -0,0 +1,32 @@ + + + + + + + File Uploads + + + +
+ +
+
+ + + +
+ + + +
+ +
+ + + +
+ +
+ + \ No newline at end of file diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..638706f --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,18 @@ +FROM node:20 + +WORKDIR /user/src/app + +COPY ./package.json ./ +COPY ./bun.lockb ./ + +RUN npm install -g bun +RUN bun install + +COPY . . + +# EXPOSE 3000 +EXPOSE 3003 + +RUN bun run build +# CMD ["bun", "dev", "--host"] +CMD ["bun", "run", "start", "--host", "0.0.0.0"] \ No newline at end of file diff --git a/frontend/bun.lockb b/frontend/bun.lockb index 08edcba..8f7e383 100755 Binary files a/frontend/bun.lockb and b/frontend/bun.lockb differ diff --git a/frontend/package.json b/frontend/package.json index 74fbc89..409d054 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -15,6 +15,7 @@ "next": "14.1.4", "react": "^18", "react-dom": "^18", + "sharp": "^0.33.4", "tailwind-merge": "^2.2.2", "tailwindcss-animate": "^1.0.7" }, diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index c23c824..deb52d6 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -18,7 +18,7 @@ } ], "paths": { - "@/*": ["frontend/src/*"] + "@/*": ["./frontend/src/*"] } }, "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],