Remove swagger
This commit is contained in:
14
app.py
14
app.py
@@ -1,20 +1,16 @@
|
|||||||
import os
|
import os
|
||||||
from flask import Flask, render_template, redirect, request, url_for
|
from flask import Flask, render_template, redirect, request, url_for
|
||||||
from flasgger import Swagger, swag_from
|
|
||||||
|
|
||||||
from db import DataBase
|
|
||||||
from decorators import validate_person, validate_topset, validate_workout
|
from decorators import validate_person, validate_topset, validate_workout
|
||||||
|
from db import DataBase
|
||||||
from utils import get_people_and_exercise_rep_maxes
|
from utils import get_people_and_exercise_rep_maxes
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_pyfile('config.py')
|
app.config.from_pyfile('config.py')
|
||||||
swagger = Swagger(app, template_file='swagger/base.json')
|
|
||||||
|
|
||||||
db = DataBase(app)
|
db = DataBase(app)
|
||||||
|
|
||||||
|
|
||||||
@ app.route("/")
|
@ app.route("/")
|
||||||
@ swag_from('swagger/dashboard.yml')
|
|
||||||
def dashboard():
|
def dashboard():
|
||||||
all_topsets = db.get_all_topsets()
|
all_topsets = db.get_all_topsets()
|
||||||
people_and_exercise_rep_maxes = get_people_and_exercise_rep_maxes(
|
people_and_exercise_rep_maxes = get_people_and_exercise_rep_maxes(
|
||||||
@@ -23,7 +19,6 @@ def dashboard():
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>")
|
@ app.route("/person/<int:person_id>")
|
||||||
@ swag_from('swagger/get_person.yml')
|
|
||||||
@ validate_person
|
@ validate_person
|
||||||
def get_person(person_id):
|
def get_person(person_id):
|
||||||
person = db.get_person_final(person_id)
|
person = db.get_person_final(person_id)
|
||||||
@@ -31,7 +26,6 @@ def get_person(person_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout", methods=['POST'])
|
@ app.route("/person/<int:person_id>/workout", methods=['POST'])
|
||||||
@ swag_from('swagger/create_workout.yml')
|
|
||||||
@ validate_person
|
@ validate_person
|
||||||
def create_workout(person_id):
|
def create_workout(person_id):
|
||||||
new_workout_id = db.create_workout(person_id)
|
new_workout_id = db.create_workout(person_id)
|
||||||
@@ -39,7 +33,6 @@ def create_workout(person_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>")
|
@ app.route("/person/<int:person_id>/workout/<int:workout_id>")
|
||||||
@ swag_from('swagger/get_workout.yml')
|
|
||||||
@ validate_workout
|
@ validate_workout
|
||||||
def get_workout(person_id, workout_id):
|
def get_workout(person_id, workout_id):
|
||||||
workout = db.get_workout_final(person_id, workout_id)
|
workout = db.get_workout_final(person_id, workout_id)
|
||||||
@@ -47,7 +40,6 @@ def get_workout(person_id, workout_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/delete", methods=['GET', 'DELETE'])
|
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/delete", methods=['GET', 'DELETE'])
|
||||||
@ swag_from('swagger/delete_workout.yml')
|
|
||||||
@ validate_workout
|
@ validate_workout
|
||||||
def delete_workout(person_id, workout_id):
|
def delete_workout(person_id, workout_id):
|
||||||
db.delete_workout(workout_id)
|
db.delete_workout(workout_id)
|
||||||
@@ -55,7 +47,6 @@ def delete_workout(person_id, workout_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>", methods=['GET', 'POST'])
|
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>", methods=['GET', 'POST'])
|
||||||
@ swag_from('swagger/get_topset.yml')
|
|
||||||
@ validate_topset
|
@ validate_topset
|
||||||
def get_topset(person_id, workout_id, topset_id):
|
def get_topset(person_id, workout_id, topset_id):
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
@@ -72,7 +63,6 @@ def get_topset(person_id, workout_id, topset_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/topset", methods=['POST'])
|
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/topset", methods=['POST'])
|
||||||
@ swag_from('swagger/create_topset.yml')
|
|
||||||
@ validate_workout
|
@ validate_workout
|
||||||
def create_topset(person_id, workout_id):
|
def create_topset(person_id, workout_id):
|
||||||
exercise_id = request.form.get("exercise_id")
|
exercise_id = request.form.get("exercise_id")
|
||||||
@@ -84,7 +74,6 @@ def create_topset(person_id, workout_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>/delete", methods=['GET', 'DELETE'])
|
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/topset/<int:topset_id>/delete", methods=['GET', 'DELETE'])
|
||||||
@ swag_from('swagger/delete_topset.yml')
|
|
||||||
@ validate_topset
|
@ validate_topset
|
||||||
def delete_topset(person_id, workout_id, topset_id):
|
def delete_topset(person_id, workout_id, topset_id):
|
||||||
db.delete_topset(topset_id)
|
db.delete_topset(topset_id)
|
||||||
@@ -118,7 +107,6 @@ def delete_exercise(exercise_id):
|
|||||||
|
|
||||||
|
|
||||||
@ app.route("/settings")
|
@ app.route("/settings")
|
||||||
@ swag_from('swagger/dashboard.yml')
|
|
||||||
def settings():
|
def settings():
|
||||||
people = db.get_people()
|
people = db.get_people()
|
||||||
exercises = db.get_exercises()
|
exercises = db.get_exercises()
|
||||||
|
|||||||
@@ -2,4 +2,3 @@ TESTING = True
|
|||||||
DEBUG = True
|
DEBUG = True
|
||||||
FLASK_ENV = 'development'
|
FLASK_ENV = 'development'
|
||||||
SECRET_KEY = ''
|
SECRET_KEY = ''
|
||||||
DATABASE_URI = 'workout.db'
|
|
||||||
|
|||||||
17
db.py
17
db.py
@@ -9,21 +9,14 @@ from utils import get_all_exercises_from_topsets, get_people_and_exercise_rep_ma
|
|||||||
|
|
||||||
class DataBase():
|
class DataBase():
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.DATABASE_URI = app.config['DATABASE_URI']
|
|
||||||
|
|
||||||
db_url = urlparse(os.environ['DATABASE_URL'])
|
db_url = urlparse(os.environ['DATABASE_URL'])
|
||||||
username = db_url.username
|
|
||||||
password = db_url.password
|
|
||||||
database = db_url.path[1:]
|
|
||||||
hostname = db_url.hostname
|
|
||||||
port = db_url.port
|
|
||||||
|
|
||||||
self.conn = psycopg2.connect(
|
self.conn = psycopg2.connect(
|
||||||
database=database,
|
database=db_url.path[1:],
|
||||||
user=username,
|
user=db_url.username,
|
||||||
password=password,
|
password=db_url.password,
|
||||||
host=hostname,
|
host=db_url.hostname,
|
||||||
port=port
|
port=db_url.port
|
||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, query, args=(), one=False, commit=False):
|
def execute(self, query, args=(), one=False, commit=False):
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
Flask==2.0.1
|
Flask==2.0.1
|
||||||
gunicorn==19.7.1
|
gunicorn==19.7.1
|
||||||
Jinja2==3.0.1
|
Jinja2==3.0.1
|
||||||
flasgger==0.9.5
|
|
||||||
psycopg2-binary==2.9.3
|
psycopg2-binary==2.9.3
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"swagger": "2.0",
|
|
||||||
"info": {
|
|
||||||
"title": "WorkoutTracker API",
|
|
||||||
"description": "API for tracking topsets of workouts",
|
|
||||||
"contact": {
|
|
||||||
"responsibleOrganization": "ME",
|
|
||||||
"responsibleDeveloper": "Me",
|
|
||||||
"email": "me@me.com",
|
|
||||||
"url": "www.me.com"
|
|
||||||
},
|
|
||||||
"version": "0.0.1"
|
|
||||||
},
|
|
||||||
"schemes": ["http", "https"],
|
|
||||||
"operationId": "getmyData"
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
Add top set to workout
|
|
||||||
Add a topset to a workout completed by a person
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Topset
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: workout_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: A list of topsets in a selected workout
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
Create new workout
|
|
||||||
Creates a workout with current date and then redirects to newly created workout
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Workout
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: View of newly created workout
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
Dashboard page
|
|
||||||
Displays stats and a list of all people and there rep maxes for each exercise
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Dashboard
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: A list of all people and there rep maxes for each exercise
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
Delete top set
|
|
||||||
Add a topset to a workout completed by a person
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Topset
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: workout_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: topset_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: A list of topsets in a selected workout
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
Delete workout
|
|
||||||
Deletes selected workout completed by a person
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Workout
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: workout_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: Redirect to workouts list page for person
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
Display all workouts for a person
|
|
||||||
Displays stats and a list of all people and there rep maxes for each exercise
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Person
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
equired: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: A list of all people and there rep maxes for each exercise
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
Display/Create new top set
|
|
||||||
Displays stats and a list of all people and there rep maxes for each exercise
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Topset
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: workout_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: topset_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: A list of topsets in a selected workout
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
Display a workout
|
|
||||||
Displays a selected workout with options to edit/delete existing and add new topsets
|
|
||||||
---
|
|
||||||
tags:
|
|
||||||
- Workout
|
|
||||||
parameters:
|
|
||||||
- name: person_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
- name: workout_id
|
|
||||||
in: path
|
|
||||||
type: number
|
|
||||||
required: true
|
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: A list of topsets in a selected workout
|
|
||||||
@@ -42,21 +42,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<a href="/apidocs">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
||||||
aria-hidden="true" role="img" id="footer-icon-name" class="w-6 h-6"
|
|
||||||
preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256">
|
|
||||||
<path fill="#85EA2D"
|
|
||||||
d="M127.999 249.895c-67.215 0-121.9-54.68-121.9-121.896C6.1 60.782 60.785 6.102 128 6.102c67.214 0 121.899 54.685 121.899 121.9c0 67.214-54.685 121.893-121.9 121.893Z">
|
|
||||||
</path>
|
|
||||||
<path fill="#173647"
|
|
||||||
d="M127.999 12.202c63.954 0 115.797 51.842 115.797 115.797c0 63.952-51.843 115.797-115.797 115.797c-63.952 0-115.797-51.845-115.797-115.797S64.047 12.202 127.999 12.202m0-12.202C57.419 0 0 57.42 0 127.999s57.42 127.998 127.999 127.998S256 198.577 256 128C256 57.419 198.578 0 127.999 0Z">
|
|
||||||
</path>
|
|
||||||
<path fill="#173647"
|
|
||||||
d="M80.598 86.619c-.394 4.38.146 8.909-.146 13.338c-.345 4.431-.887 8.811-1.773 13.192c-1.23 6.25-5.12 10.976-10.482 14.914c10.436 6.793 11.616 17.324 12.304 28.006c.345 5.76.197 11.567.788 17.276c.443 4.429 2.165 5.562 6.745 5.708c1.87.048 3.786 0 5.956 0v13.683c-13.535 2.313-24.708-1.525-27.467-12.992c-.887-4.184-1.478-8.467-1.673-12.798c-.297-4.578.195-9.155-.148-13.732c-.985-12.553-2.61-16.785-14.618-17.376v-15.602a23.714 23.714 0 0 1 2.608-.443c6.596-.345 9.4-2.364 10.828-8.86c.69-3.641 1.084-7.333 1.23-11.074c.494-7.136.297-14.42 1.525-21.507C67.997 68.163 74.3 63.24 84.785 62.65c2.952-.149 5.955 0 9.35 0v13.98c-1.427.1-2.658.294-3.937.294c-8.515-.297-8.96 2.607-9.6 9.695Zm16.39 32.386h-.196c-4.923-.245-9.155 3.593-9.403 8.515c-.246 4.972 3.592 9.206 8.515 9.45h.59c4.875.296 9.056-3.447 9.352-8.319v-.491c.1-4.971-3.886-9.055-8.857-9.155Zm30.862 0c-4.774-.148-8.763 3.593-8.909 8.318c0 .297 0 .543.051.837c0 5.365 3.641 8.812 9.155 8.812c5.414 0 8.812-3.544 8.812-9.106c-.051-5.366-3.646-8.91-9.109-8.86Zm31.602 0c-5.02-.1-9.206 3.89-9.352 8.91a9.03 9.03 0 0 0 9.055 9.054h.1c4.528.788 9.106-3.592 9.402-8.858c.243-4.874-4.186-9.106-9.205-9.106Zm43.363.737c-5.711-.245-8.567-2.164-9.992-7.581a54.874 54.874 0 0 1-1.624-10.582c-.395-6.596-.346-13.241-.789-19.837c-1.033-15.651-12.352-21.114-28.794-18.41V76.92c2.607 0 4.626 0 6.645.049c3.495.048 6.153 1.379 6.496 5.268c.345 3.543.345 7.136.69 10.73c.692 7.139 1.083 14.372 2.314 21.41c1.085 5.809 5.07 10.14 10.04 13.684c-8.71 5.857-11.27 14.223-11.714 23.626c-.245 6.448-.394 12.944-.736 19.443c-.297 5.905-2.362 7.824-8.318 7.972c-1.674.05-3.298.198-5.169.297v13.93c3.495 0 6.694.196 9.892 0c9.942-.592 15.947-5.415 17.918-15.063a125.582 125.582 0 0 0 1.476-16.045c.343-4.923.297-9.894.788-14.766c.737-7.63 4.232-10.78 11.862-11.27c.739-.1 1.427-.246 2.118-.492v-15.604c-1.282-.149-2.17-.295-3.103-.346Z">
|
|
||||||
</path>
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
<a href="https://github.com/GabePope/WorkoutTracker"
|
<a href="https://github.com/GabePope/WorkoutTracker"
|
||||||
class="ml-6 block text-slate-400 hover:text-slate-500 dark:hover:text-slate-300"><span
|
class="ml-6 block text-slate-400 hover:text-slate-500 dark:hover:text-slate-300"><span
|
||||||
class="sr-only">Workout Tracker on GitHub</span><svg viewBox="0 0 16 16" class="w-6 h-6"
|
class="sr-only">Workout Tracker on GitHub</span><svg viewBox="0 0 16 16" class="w-6 h-6"
|
||||||
@@ -64,8 +49,8 @@
|
|||||||
<path
|
<path
|
||||||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z">
|
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z">
|
||||||
</path>
|
</path>
|
||||||
</svg></a>
|
</svg>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user