Spaces:
Running
on
Zero
Running
on
Zero
templates, port
Browse files- Dockerfile +0 -2
- app.py +3 -5
- requirements.txt +0 -1
- templates/index.html +12 -0
Dockerfile
CHANGED
@@ -46,7 +46,5 @@ RUN echo '#!/bin/bash\nredis-server --daemonize yes\npython app.py' > /app/start
|
|
46 |
RUN useradd -m appuser && chown -R appuser:appuser /app
|
47 |
USER appuser
|
48 |
|
49 |
-
EXPOSE 5000
|
50 |
-
|
51 |
# 起動コマンドを変更
|
52 |
CMD ["/app/start.sh"]
|
|
|
46 |
RUN useradd -m appuser && chown -R appuser:appuser /app
|
47 |
USER appuser
|
48 |
|
|
|
|
|
49 |
# 起動コマンドを変更
|
50 |
CMD ["/app/start.sh"]
|
app.py
CHANGED
@@ -24,7 +24,6 @@ from gevent import pywsgi
|
|
24 |
from geventwebsocket.handler import WebSocketHandler
|
25 |
|
26 |
app = Flask(__name__)
|
27 |
-
# app.secret_key = 'super_secret_key'
|
28 |
CORS(app)
|
29 |
socketio = SocketIO(app, cors_allowed_origins="*")
|
30 |
|
@@ -207,7 +206,7 @@ def handle_disconnect():
|
|
207 |
# ルートパスのGETリクエストに対するハンドラ
|
208 |
@app.route('/', methods=['GET'])
|
209 |
def root():
|
210 |
-
return
|
211 |
|
212 |
# process_refined のエンドポイント
|
213 |
@app.route('/process_refined', methods=['POST'])
|
@@ -260,12 +259,11 @@ if __name__ == '__main__':
|
|
260 |
parser.add_argument('--use_local', action='store_true', help='Use local model')
|
261 |
parser.add_argument('--use_gpu', action='store_true', help='Set to True to use GPU but if not available, it will use CPU')
|
262 |
parser.add_argument('--use_dotenv', action='store_true', help='Use .env file for environment variables')
|
263 |
-
parser.add_argument('--debug', action='store_true', help='Run in debug mode')
|
264 |
|
265 |
args = parser.parse_args()
|
266 |
|
267 |
-
|
268 |
-
port = int(os.environ
|
269 |
print(f"Starting server on port {port}")
|
270 |
server = pywsgi.WSGIServer(('0.0.0.0', port), app, handler_class=WebSocketHandler)
|
271 |
server.serve_forever()
|
|
|
24 |
from geventwebsocket.handler import WebSocketHandler
|
25 |
|
26 |
app = Flask(__name__)
|
|
|
27 |
CORS(app)
|
28 |
socketio = SocketIO(app, cors_allowed_origins="*")
|
29 |
|
|
|
206 |
# ルートパスのGETリクエストに対するハンドラ
|
207 |
@app.route('/', methods=['GET'])
|
208 |
def root():
|
209 |
+
return render_template("index.html")
|
210 |
|
211 |
# process_refined のエンドポイント
|
212 |
@app.route('/process_refined', methods=['POST'])
|
|
|
259 |
parser.add_argument('--use_local', action='store_true', help='Use local model')
|
260 |
parser.add_argument('--use_gpu', action='store_true', help='Set to True to use GPU but if not available, it will use CPU')
|
261 |
parser.add_argument('--use_dotenv', action='store_true', help='Use .env file for environment variables')
|
|
|
262 |
|
263 |
args = parser.parse_args()
|
264 |
|
265 |
+
initialize(args.use_local, args.use_gpu, args.use_dotenv)
|
266 |
+
port = int(os.environ.get('PORT', 7860))
|
267 |
print(f"Starting server on port {port}")
|
268 |
server = pywsgi.WSGIServer(('0.0.0.0', port), app, handler_class=WebSocketHandler)
|
269 |
server.serve_forever()
|
requirements.txt
CHANGED
@@ -15,7 +15,6 @@ Pillow==10.3.0
|
|
15 |
Requests==2.32.3
|
16 |
tensorflow==2.16.1
|
17 |
transforms==0.2.1
|
18 |
-
transformers==4.42.3
|
19 |
tokenizers
|
20 |
pytorch_lightning
|
21 |
python-dotenv
|
|
|
15 |
Requests==2.32.3
|
16 |
tensorflow==2.16.1
|
17 |
transforms==0.2.1
|
|
|
18 |
tokenizers
|
19 |
pytorch_lightning
|
20 |
python-dotenv
|
templates/index.html
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>{{ title }}</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>Welcome to our website</h1>
|
10 |
+
<p>This is the home page rendered using a Flask template.</p>
|
11 |
+
</body>
|
12 |
+
</html>
|