Skip to content

Instantly share code, notes, and snippets.

@harilee1325
Last active August 23, 2019 16:12
Show Gist options
  • Save harilee1325/6117c03bd606813a697dfb394aca9b67 to your computer and use it in GitHub Desktop.
Save harilee1325/6117c03bd606813a697dfb394aca9b67 to your computer and use it in GitHub Desktop.
from flask import Flask, request, jsonify
import json as simplejson
from bson.json_util import dumps
app = Flask(__name__)
@app.route("/")
def hello():
return "Welcome to Python Flask, hello coder!"
@app.route("/login/<string:username>/<string:password>", methods=['GET'])
def login_user(username, password):
try:
return dumps ({ 'success':'yes','username':username, 'password': password})
except Exception as e:
return dumps({'error' : str(e)})
@app.route("/user-create", methods = ['POST'])
def create_user():
try:
# accepts data in the body of the method
user_name = request.form['username']
password = request.form['password']
return dumps ({'success':'yes','username':user_name,'password':password})
except Exception as e:
return dumps({'error' : str(e)})
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment