added backend folder and began flask, update gitignore

This commit is contained in:
Jacob Delgado 2024-08-08 10:00:24 -07:00
parent a9646f30f7
commit 71815a6533
10 changed files with 128 additions and 1 deletions

1
backend/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/ven

18
backend/Dockerfile Normal file
View File

@ -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"]

29
backend/config.py Normal file
View File

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

21
backend/main.py Normal file
View File

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

7
backend/requirements.txt Normal file
View File

@ -0,0 +1,7 @@
flask
flask-sqlalchemy
flask-bcrypt
flask-cors
python-dotenv
flask-session
redis

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Uploads</title>
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
</head>
<body>
<div class="app">
<div class="form-section">
<form aciton="/api/upload" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit" name="Upload">
</form>
<!-- Form will go here -->
</div>
<div class="images-section">
<!-- Images will go here -->
</div>
</div>
</body>
</html>

18
frontend/Dockerfile Normal file
View File

@ -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"]

Binary file not shown.

View File

@ -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"
},

View File

@ -18,7 +18,7 @@
}
],
"paths": {
"@/*": ["frontend/src/*"]
"@/*": ["./frontend/src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],