Initial commit: Flask hello app
This commit is contained in:
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
COPY app.py .
|
||||||
|
|
||||||
|
EXPOSE 5000
|
||||||
|
|
||||||
|
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "app:app"]
|
||||||
33
README.md
Normal file
33
README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Flask Hello App
|
||||||
|
|
||||||
|
Простое Flask веб-приложение для тестирования деплоя в Coolify.
|
||||||
|
|
||||||
|
## Endpoints
|
||||||
|
|
||||||
|
| Endpoint | Description |
|
||||||
|
|----------|-------------|
|
||||||
|
| `GET /` | Hello world |
|
||||||
|
| `GET /health` | Health check |
|
||||||
|
| `GET /api/greet?name=YourName` | Greeting API |
|
||||||
|
|
||||||
|
## Local Development
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
python app.py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t flask-hello .
|
||||||
|
docker run -p 5000:5000 flask-hello
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl http://localhost:5000/
|
||||||
|
curl http://localhost:5000/health
|
||||||
|
curl http://localhost:5000/api/greet?name=Miru
|
||||||
|
```
|
||||||
36
app.py
Normal file
36
app.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
from flask import Flask, jsonify, request
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def hello():
|
||||||
|
"""Hello world route"""
|
||||||
|
return jsonify({
|
||||||
|
'message': 'Hello, World!',
|
||||||
|
'app': 'flask-hello',
|
||||||
|
'status': 'running'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/health')
|
||||||
|
def health():
|
||||||
|
"""Health check route"""
|
||||||
|
return jsonify({
|
||||||
|
'status': 'healthy',
|
||||||
|
'service': 'flask-hello'
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/greet')
|
||||||
|
def greet():
|
||||||
|
"""Greeting API endpoint"""
|
||||||
|
name = request.args.get('name', 'Friend')
|
||||||
|
return jsonify({
|
||||||
|
'greeting': f'Hello, {name}!',
|
||||||
|
'name': name
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=5000)
|
||||||
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
flask==3.0.0
|
||||||
|
gunicorn==21.2.0
|
||||||
Reference in New Issue
Block a user