Skip to content

Instantly share code, notes, and snippets.

@Vibhu-Agarwal
Created October 16, 2019 09:09
Show Gist options
  • Save Vibhu-Agarwal/59e900b2015a1dc778013b1b62036dd9 to your computer and use it in GitHub Desktop.
Save Vibhu-Agarwal/59e900b2015a1dc778013b1b62036dd9 to your computer and use it in GitHub Desktop.
A simple Flask Server with POST request.
## ----------------------------------------------------------------------------------------------- ##
## ---------------------------------- Necessary Flask Modules ------------------------------------ ##
from flask import Flask, render_template, request, jsonify, make_response
## ----------------------------------------------------------------------------------------------- ##
## ----------------------------------------------------------------------------------------------- ##
## --------------- Initialising the flask object and registering github blueprint ---------------- ##
app = Flask(__name__)
# website_url = ""
## ----------------------------------------------------------------------------------------------- ##
@app.route('/', methods = ['POST'])
def api():
params = request.form
print('->', params['name_name'])
response = {"Name": "Working"}
response = make_response(jsonify(response), 200)
response.headers['Content-Type'] = 'application/json'
return response
if __name__ == '__main__':
# app.config['SERVER_NAME'] = website_url
app.config['JSON_SORT_KEYS'] = False
app.debug = False
# os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' ##in_production
port = 5000
app.run(host = '0.0.0.0', port=port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment