charbelmalo commited on
Commit
8d5a0fc
·
2 Parent(s): 9e7f457 74adb83

Merge remote-tracking branch 'origin/main'

Browse files
Files changed (4) hide show
  1. Dockerfile +18 -15
  2. README.md +1 -0
  3. app.py +21 -5
  4. requirements.txt +4 -2
Dockerfile CHANGED
@@ -1,27 +1,30 @@
1
  # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
3
 
4
- # Set environment variables to reduce Python buffering and prevent .pyc files
 
 
 
 
 
 
 
5
  ENV PYTHONDONTWRITEBYTECODE=1
6
  ENV PYTHONUNBUFFERED=1
7
 
8
- # Create a non-root user to run the app
9
- RUN useradd -m -u 1000 appuser
10
- USER appuser
11
-
12
  # Set the working directory
13
  WORKDIR /app
14
 
15
  # Copy and install dependencies
16
- COPY --chown=appuser:appuser requirements.txt .
17
- RUN pip install --no-cache-dir --upgrade pip && \
18
- pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy the application code
21
- COPY --chown=appuser:appuser . .
22
 
23
- # Expose the port FastAPI will run on
24
- EXPOSE 7860
25
 
26
- # Command to run the application
27
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  # Use an official Python runtime as a parent image
2
+ FROM python:3.10-slim
3
 
4
+ # Create a user with a non-root UID
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Switch to the non-root user
8
+ USER user
9
+
10
+ # Set environment variables
11
+ ENV PATH="/home/user/.local/bin:$PATH"
12
  ENV PYTHONDONTWRITEBYTECODE=1
13
  ENV PYTHONUNBUFFERED=1
14
 
 
 
 
 
15
  # Set the working directory
16
  WORKDIR /app
17
 
18
  # Copy and install dependencies
19
+ COPY --chown=user: /app/requirements.txt .
20
+ RUN pip install --no-cache-dir --upgrade pip
21
+ RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy the rest of the application code
24
+ COPY --chown=user: /app /app
25
 
26
+ # Expose the port your app runs on
27
+ EXPOSE 8080
28
 
29
+ # Define the command to run the app using Gunicorn
30
+ CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
README.md CHANGED
@@ -7,6 +7,7 @@ sdk: docker
7
  pinned: false
8
  license: apache-2.0
9
  short_description: Ultimate Website URL AI Manager
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
7
  pinned: false
8
  license: apache-2.0
9
  short_description: Ultimate Website URL AI Manager
10
+ app_port: 8080
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,7 +1,23 @@
1
- from fastapi import FastAPI
2
 
3
- app = FastAPI()
4
 
5
- @app.get("/")
6
- def greet_json():
7
- return {"Hello": "World!"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request, jsonify
2
 
3
+ app = Flask(__name__)
4
 
5
+ # Sample route for homepage
6
+ @app.route('/')
7
+ def home():
8
+ return "Welcome to LinkMaster!"
9
+
10
+ # Example route to manage tags
11
+ @app.route('/tags', methods=['GET', 'POST'])
12
+ def manage_tags():
13
+ if request.method == 'POST':
14
+ # Logic to add a new tag
15
+ pass
16
+ else:
17
+ # Logic to retrieve tags
18
+ return jsonify({"tags": []})
19
+
20
+ # Add more routes as needed for your application
21
+
22
+ if __name__ == '__main__':
23
+ app.run(host='0.0.0.0', port=8080)
requirements.txt CHANGED
@@ -1,3 +1,5 @@
 
 
 
 
1
  sqlalchemy
2
- fastapi
3
- uvicorn[standard]
 
1
+ gunicorn==20.1.0
2
+ flask
3
+ flask_cors
4
+ flask_sqlalchemy
5
  sqlalchemy