Answers for "flask api project"

13

simple flask app

# Extremely simple flask application, will display 'Hello World!' on the screen when you run it
# Access it by running it, then going to whatever port its running on (It'll say which port it's running on).
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()
Posted by: Guest on July-31-2020
6

python flask rest api

from flask import Flask
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)

class HelloWorld(Resource):
    def get(self):
        return {'hello': 'world'}

api.add_resource(HelloWorld, '/')

if __name__ == '__main__':
    app.run(debug=True)
Posted by: Guest on March-27-2021
1

creating an apis with python and flask

""" This website does pretty-good explanation with a working example
    
    https://programminghistorian.org/en/lessons/creating-apis-with-python-and-flask
"""
Posted by: Guest on May-10-2021

Python Answers by Framework

Browse Popular Code Answers by Language