Skip to content
Snippets Groups Projects
app.py 436 B
Newer Older
  • Learn to ignore specific revisions
  • MESLI Mohamed's avatar
    MESLI Mohamed committed
    from flask import Flask
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    import json
    
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    app=Flask(__name__)
    
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    @app.route("/plus_one")
    def plus_one():
      x= int(request.args.get('x', 1))
      return json.dumps({'x': x + 1 })
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    @app.route("/plus_two")
    def plus_two():
      x = int(request.args.get('x', 1))
      return json.dumps({'x': x + 2})
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    
    
    MESLI Mohamed's avatar
    MESLI Mohamed committed
    @app.route("/square")
    def square():
      x = int(request.args.get('x', 1)) 
      return json.dumps({'x': x * x})
    
    if __name__ == '__main__':
     app.run(debug=True)