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 1 pip install Flask Then, create a new file named app.py and add the following code: python 1 from flask import Flask , render_template , request 2 3 app = Flask ( __name__ ) 4 5 @app . route ( '/' , methods = [ 'GET' , 'POST' ] ) 6 def 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 15 if __name__ == '__main__' : 16 app . run ( debug = True ) Next, create a new folder named templates in the same di...
Comments
Post a Comment