How to create flask web application:
Creating a Flask web application is a straightforward process. Here are the basic steps to get you started:
1. Install Flask: First, make sure you have Python installed on your system. Then, install Flask using pip:
pip install flask |
2. Create a Flask App: Create a new Python file (e.g., app.py) and import Flask:
from flask import Flask app = Flask(__name__) |
3. Define Routes: Use decorators to define routes for your app.
For example:
@app.route('/') def home(): return 'Hello, Flask!' |
4. Run the App: In your terminal or command prompt, navigate to your project folder and run:
flask run |
This will start your Flask app, and you can access it in your browser at http://localhost:5000.
No comments:
Post a Comment