Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to write post method using flask

from flask import Flask
from flask import request

app = Flask(__name__)

@app.route('/users/<user_id>', methods = ['GET', 'POST', 'DELETE'])
def user(user_id):
    if request.method == 'GET':
        """return the information for <user_id>"""
        .
        .
        .
    if request.method == 'POST':
        """modify/update the information for <user_id>"""
        # you can use <user_id>, which is a str but could
        # changed to be int or whatever you want, along
        # with your lxml knowledge to make the required
        # changes
        data = request.form # a multidict containing POST data
        .
        .
        .
    if request.method == 'DELETE':
        """delete user with ID <user_id>"""
        .
        .
        .
    else:
        # POST Error 405 Method Not Allowed
        .
        .
        .
Comment

PREVIOUS NEXT
Code Example
Python :: find length of text file python 
Python :: How to perform Bubble sort in Python? 
Python :: pandas select a row 
Python :: python vs c++ 
Python :: python timer decorator 
Python :: numpy as array 
Python :: pandas pivot 
Python :: E: Unable to locate package python-gobject 
Python :: return count of substring in a string 
Python :: how to check libraries in python 
Python :: visitor IP address django 
Python :: Double-Linked List Python 
Python :: check integer number python 
Python :: pandas take first n rows 
Python :: pyauto gui save screenshot 
Python :: how to create model in tensorflow 
Python :: python time function in for loop 
Python :: django ModelChoiceField value not id 
Python :: all pdf in a directory to csv python 
Python :: how to use static files in django 
Python :: installation of uvicorn with only pure python dependencies 
Python :: seaborn boxplot 
Python :: graph 3d python 
Python :: move column in pandas 
Python :: pyside 
Python :: django get form data from post 
Python :: django login view 
Python :: change value in excel using python 
Python :: import argv python 
Python :: program to print duplicates from a list of integers in python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =