Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **NOTE FROM ULTRAPRIM: A few things needed to be debugged. For the frontend, I needed to change the https to http for the url
- For the backend, line 4 and 20 needed to be changed. I also added a "print(request.get_data()) on line 15.
- See final python code at EOF
- Write a html web application that takes the users name and password, then sends this data as a post request to localhost port 7000
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>PHP Web Application</title>
- </head>
- <body>
- <form method="post" action="https://localhost:7000/">
- <input type="text" name="name" placeholder="John">
- <input type="password" name="password" placeholder="password">
- <input type="submit" value="Submit">
- </form>
- </body>
- </html>
- **END OF FIRST COMPLETION. This is when I gave instruction to write the backend
- Now write python3 code to handle a post from this code.
- from flask import Flask
- app = Flask(__name__)
- @app.route("/")
- def index():
- name = request.args.get('name', '')
- password = request.args.get('password', '')
- print('Name: ' + name + ' Password: ' + password)
- return 'Hello,
- '
- if __name__ == '__main__':
- app.run()
- ---------------------------
- DEBUGGED PYTHON CODE: **Computer did not supply this.
- from flask import Flask
- from flask import request
- app = Flask(__name__)
- @app.route("/", methods=['GET', 'POST'])
- def index():
- name = request.args.get('name', '')
- password = request.args.get('password', '')
- print('Name: ' + name + ' Password: ' + password)
- print(request.get_data())
- return 'Hello, '
- if __name__ == '__main__':
- app.run(port=7000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement