Skip to content

Instantly share code, notes, and snippets.

@BolaNasr
Created August 16, 2018 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BolaNasr/3945e6d5e5d268fa74c0045a67a250ae to your computer and use it in GitHub Desktop.
Save BolaNasr/3945e6d5e5d268fa74c0045a67a250ae to your computer and use it in GitHub Desktop.
simple flask server
from flask import Flask, render_template, request, jsonify
from pusher import Pusher
import json
# create flask app
app = Flask(__name__)
# index route, shows index.html view
@app.route('/')
def index():
return "Welcome To Flask Server"
# endpoint for storing todo item
@app.route('/Add', methods=['POST'])
def add():
#data = json.loads(request.data) # load JSON data from request
# trigger `item-added` event on `todo` channel
#pusher.trigger('todo', 'item-added', data)
return "you add new Item"
# endpoint for deleting todo item
@app.route('/remove/<item_id>')
def remove(item_id):
#data = {'id': item_id}
#pusher.trigger('todo', 'item-removed', data)
return "you delete specific utem"
# endpoint for updating todo item
@app.route('/update/<item_id>', methods=['POST'])
def update(item_id):
#data = {
# 'id': item_id,
# 'completed': json.loads(request.data).get('completed', 0)
#}
#pusher.trigger('todo', 'item-updated', data)
return "You update specific Item"
# run Flask app in debug mode
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment