Compare commits

...

5 Commits

Author SHA1 Message Date
c945a2adb6 .envを削除し.gitignoreに追加 2025-06-14 08:16:07 +09:00
f6ba77e533 DBを定義 2025-06-13 23:02:48 +09:00
a7ed4d06fb __init__.pyを大まかに作成 2025-06-13 22:09:21 +09:00
e30a0a6f9b run.py __init__.pyの形をとりあえず作成 2025-06-10 13:08:08 +09:00
43f53fe79b 実装をPythonに変更 2025-06-09 13:21:22 +09:00
42 changed files with 105 additions and 27 deletions

3
.gitignore vendored
View File

@ -1 +1,2 @@
develop.md
develop.md
.env

View File

@ -1 +0,0 @@


View File

@ -3,8 +3,8 @@
技術スタックは以下の通り
- Go
- Gin
- Python
- Flask
- JavaScript
- Bootstrap or Tailwind テンプレート(未定)
- MySQL

25
app/__init__.py Normal file
View File

@ -0,0 +1,25 @@
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
import os
# db = SQLAlchemy()
login_manager = LoginManager()
#login_manager.login_view = 'auth.login'
login_manager.login_message_category = 'info'
# TODO:DB設定などのコードを書く
def create_app():
app = Flask(__name__)
# TODO:シークレットキーは設定ファイルで管理
app.config['SECRET_KEY'] = 'secret'
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:password@localhost/workout'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
#db.init_app(app)
#login_manager.init_app(app)
#with app.app_context():
#db.create_all()
return app

0
app/models/__init__.py Normal file
View File

65
app/models/workout.py Normal file
View File

@ -0,0 +1,65 @@
from . import db
from datetime import datetime, date
class User(db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(80), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=True)
password_hash = db.Column(db.String(128), nullable=False)
profile_image_url = db.Column(db.String(255), nullable=True)
bio = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
workouts = db.relationship('Workout', backref='user', lazy=True, cascade="all, delete-orphan")
def __repr__(self):
return f'<User {self.username}>'
class Workout(db.Model):
__tablename__ = 'workouts'
id = db.Column(db.Integer, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
title = db.Column(db.String(120), nullable=False)
workout_date = db.Column(db.Date, nullable=False, default=date.today)
memo = db.Column(db.Text, nullable=True)
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
logs = db.relationship('WorkoutLog', backref='workout', lazy=True, cascade="all, delete-orphan")
def __repr__(self):
return f'<Workout {self.title} on {self.workout_date}>'
class Exercise(db.Model):
__tablename__ = 'exercises'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(120), unique=True, nullable=False)
target_muscle_group = db.Column(db.String(80), nullable=True)
description = db.Column(db.Text, nullable=True)
image_url = db.Column(db.String(255), nullable=True)
logs = db.relationship('WorkoutLog', backref='exercise', lazy=True)
def __repr__(self):
return f'<Exercise {self.name}>'
class WorkoutLog(db.Model):
__tablename__ = 'workout_logs'
id = db.Column(db.Integer, primary_key=True)
workout_id = db.Column(db.Integer, db.ForeignKey('workouts.id'), nullable=False)
exercise_id = db.Column(db.Integer, db.ForeignKey('exercises.id'), nullable=False)
set_number = db.Column(db.Integer, nullable=False)
weight = db.Column(db.Float, nullable=False)
reps = db.Column(db.Integer, nullable=False)
unit = db.Column(db.String(10), nullable=False, default='kg')
created_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
updated_at = db.Column(db.DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
def __repr__(self):
return f'<Log: Set {self.set_number} of {self.exercise.name}>'

View File

View File

0
app/routes/__init__.py Normal file
View File

View File

0
app/services/__init__.py Normal file
View File

View File

0
app/static/css/bootstrap.min.css vendored Normal file
View File

0
app/static/js/bootstrap.bundle.min.js vendored Normal file
View File

View File

View File

View File

@ -1 +0,0 @@


0
config.py Normal file
View File

View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


1
go.mod
View File

@ -1 +0,0 @@


1
go.sum
View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


View File

@ -1 +0,0 @@


5
requirements.txt Normal file
View File

@ -0,0 +1,5 @@
Flask
Flask-SQLAlchemy
PyMySQL
python-dotenv
gunicorn

6
run.py Normal file
View File

@ -0,0 +1,6 @@
from app import create_app
app = create_app()
if __name__ == '__main__':
app.run(debug=True)