Python 2 HTML

To convert this code into a user interactive web app, you can use a web framework like Flask or Django. In this example, I will use Flask. First, you need to install Flask using pip:

bash
1pip install Flask

Then, create a new file named app.py and add the following code:

python
1from flask import Flask, render_template, request 2 3app = Flask(__name__) 4 5@app.route('/', methods=['GET', 'POST']) 6def index(): 7 if request.method == 'POST': 8 input_text = request.form['input_text'] 9 result = {'status': 'success', 'result': '<pre>' + input_text + '</pre>'} 10 else: 11 result = None 12 13 return render_template('index.html', result=result) 14 15if __name__ == '__main__': 16 app.run(debug=True)

Next, create a new folder named templates in the same directory as app.py. Inside the templates folder, create a new file named index.html and add the following code:

html
1<!DOCTYPE html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <title>User Interactive Web App</title> 7</head> 8<body> 9 <h1>User Interactive Web App</h1> 10 <form action="/" method="post"> 11 <input type="text" name="input_text" /> 12 <input type="submit" value="Execute" /> 13 </form> 14 {% if result %} 15 <div>{{ result.status }}: {{ result.result }}</div> 16 {% endif %} 17</body> 18</html>

Finally, run the Flask app using the following command:

bash
1python3 app.py

Now, you can access the web app by navigating to http://localhost:5000 in your web browser.

This is a basic example of a user interactive web app

Comments

Popular posts from this blog

"Cookie Grabber", XSS Attack Example

Neko's.API