Не запускается rest приложение python
Делал rest приложение на python с некоторыми crud методами. Использовал для этого Flask, SQLAlchemy, Marshmallow и mySQL бд. Но приложение не хочет запускаться, не могу разобраться почему.
Файл crud.py:
import json
from flask import Flask, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
with open('secret.json') as f:
SECRET = json.load(f)
DB_URI = "mysql+mysqlconnector://{user}:{password}@{host}:{port}/{db}".format(
user=SECRET["user"],
password=SECRET["password"],
host=SECRET["host"],
port=SECRET["port"],
db=SECRET["db"])
app = Flask(__name__)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SQLALCHEMY_DATABASE_URI'] = DB_URI
db = SQLAlchemy(app)
ma = Marshmallow(app)
class VirtualAthletics(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(32), unique=False)
age= db.Column(db.Integer, unique=False)
creator = db.Column(db.String(32), unique=False)
def __init__(self, name, age, creator):
self.name = name
self.age = age
self.creator = creator
class VirtualAthleticsSchema(ma.Schema):
class Meta:
fields = ('name', 'age', 'creator')
virtual_athletic_schema = VirtualAthleticsSchema()
virtual_athletics_schema = VirtualAthleticsSchema(many=True)
@app.route("/virtual_athletic", methods=["POST"])
def add_virtual_athletic():
virtual_athletic = VirtualAthletics(request.json['name'],
request.json['age'],
request.json['creator'])
db.session.add(virtual_athletic)
db.session.commit()
return virtual_athletic_schema.jsonify(virtual_athletic)
@app.route("/virtual_athletic", methods=["GET"])
def get_virtual_athletic():
all_virtual_athletic = VirtualAthletics.query.all()
result = virtual_athletic_schema.dump(all_virtual_athletic)
return jsonify({'virtual_athletic': result})
if __name__ == '__main__':
db.create_all()
app.run(debug=True, host='0.0.0.0')
Файл secret.json:
{
"user": "lidl",
"password": "New_password_1",
"host": "127.0.0.1",
"port": "3306",
"db": "pythonLab"
}



