Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Python
Posted by: alphaharris
Added: Oct 12, 2018 3:52 PM
Views: 2
Tags: no tags
Simple flask-RESTful app
  1. from flask import Flask
  2. from flask_restful import Resource, Api
  3.  
  4. app = Flask(__name__)
  5. api = Api(app)
  6.  
  7.  
  8. class Student(Resource):
  9.  
  10.     def get(self, name):
  11.         return {'student': name}
  12.  
  13.  
  14. # Pass that route in instead of decorator
  15. api.add_resource(Student, '/student/<string:name>')  # http://127.0.0.1:5000/student/Rolf
  16.  
  17. app.run(port=5000)