개발/python, python frameworks
python flask - blueprint
개발자종혁
2020. 3. 12. 00:10
728x90
main.py
from flask import Flask
from test_api import test_api
app = Flask(__name__)
app.register_blueprint(test_api)
@app.route('/')
def main():
return "hello"
test_api.py
from flask import Blueprint
test_api = Blueprint('test_api', __name__, url_prefix='/test')
@test_api.route("/here")
def test():
return "here"
flask server 올린 후
request: localhost:5000/
response : hello
request: localhost:5000/test/here
response : here
728x90