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 @@ + + +
+ + + +