Stephen Sanwo
Stephen Sanwo


Stephen Sanwo

Flask Boilerplate

Photo by Zarak Khan on Unsplash

Flask Boilerplate

Stephen Sanwo's photo
Stephen Sanwo
·Jul 1, 2022·

1 min read

A simple hello world boiler plate setup for Flask API. The Flask application is initialized as app and a simple get request to the root route returns "Hello World". Note that you will have to export environment = dev in the terminal for this to work in development environment.

from flask import Flask, jsonify, request, redirect, url_for, make_response
import os

app = Flask(__name__)

# @route   GET /
# @desc    Test
# @access  Public - Test Only

@app.route('/', methods=['GET'])
def files():
    response = "Hello World"
    status = 200
    return make_response(jsonify({'response': f'{response}'}), status)

if environment == "dev":
    if __name__ == '__main__':
    if __name__ == '__main__':'', port=5000, debug=False)
Share this