How to Run a Flask framework in Python How to Run a Flask framework in Python How to Run a Flask framework in Python How to Run a Flask framework in Python How to Run a Flask framework in Python How to Run a Flask framework in Python How to Run a Flask framework in Python

 How to Run a Flask framework in Python 



from werkzeug.wrappers import Request, Response

@Request.application
def application(request):
    return Response("Hello, World!")

if __name__ == "__main__":
    from werkzeug.serving import run_simple
    run_simple("localhost", 5000, application)
How To add a Template File in Python flask
First Create a folder templates/main.html
from flask import Flask , render_template

app = Flask(__name__)

@app.route("/")
def index():
    return render_template('main.html')

if __name__ == "__main__":
	app.run(debug=True)
    #from werkzeug.serving import run_simple
    #run_simple("localhost", 5000, application)
Main.html
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap 5 Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>

<div class="container-fluid p-5 bg-primary text-white text-center">
  <h1>My First Bootstrap Page</h1>
  <p>Resize this responsive page to see the effect!</p> 
</div>
  
<div class="container mt-5">
  <div class="row">
    <div class="col-sm-4">
      <h3>Column 1</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
      <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
    </div>
    <div class="col-sm-4">
      <h3>Column 2</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
      <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
    </div>
    <div class="col-sm-4">
      <h3>Column 3</h3>        
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit...</p>
      <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris...</p>
    </div>
  </div>
</div>

</body>
</html>

How to Run in sublime tools/build system /new build
{
   "cmd": ["E:/python/python.exe", "-i", "-u", "$file"],
   "file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
   "selector": "source.python"
}
//install python and Flask

Comments

Popular posts from this blog

how manage leads mangement system user and manager auto assign in php how manage leads mangement system user and manager auto assign in php how manage leads mangement system user and manager auto assign in php

How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php How to add date filter in php