How can I structure my flask project and refactor routes into seperate files

Viewed 1077

Currently I've got all my flask routes in a single file:

from flask import Flask, render_template
from flask import jsonify, make_response


app = Flask(__name__)
app.debug = True
@app.route('/skills')
def skillchart():
    return render_template('skills.html')



@app.route('/api/skills')
def getSkills():
    skills = {
        "HTML": [], #jsonify does not support arrays, but only dictionaries.
        "CSS": [],  # also I might add skills with subskills
        "SASS": [],
        "Bootstrap": []
    }
    return jsonify(skills)

if __name__ == '__main__':
    app.run() 

How can I best refactor the routes in seperate files?(Without circular imports)

2 Answers
Related