Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app.py missing line #1

Open
walteryoung opened this issue Nov 14, 2023 · 1 comment
Open

app.py missing line #1

walteryoung opened this issue Nov 14, 2023 · 1 comment

Comments

@walteryoung
Copy link

walteryoung commented Nov 14, 2023

The example app.py in the readme fails because you are missing

from flask import Flask

@samprit-ghosh
Copy link

Creating a Flask app involves a series of steps. Flask is a lightweight web framework for Python that is widely used for building web applications. Here's a simple example to help you get started:

  1. Install Flask:
    Ensure you have Python installed on your system. You can install Flask using pip, the Python package installer. Open your terminal or command prompt and run the following command:

    pip install Flask
  2. Create Your Flask App:
    Create a new directory for your Flask app and navigate to it in the terminal.

    mkdir my_flask_app
    cd my_flask_app
  3. Create a Python Script:
    Inside your app directory, create a Python script (e.g., app.py) with the following content:

    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route('/')
    def hello_world():
        return 'Hello, World!'
    
    if __name__ == '__main__':
        app.run(debug=True)
  4. Run Your Flask App:
    In the terminal, run the following command to start your Flask app:

    python app.py

    This will start the development server, and you should see output indicating that the server is running. By default, your app will be accessible at http://127.0.0.1:5000/ or http://localhost:5000/.

  5. Access Your App:
    Open a web browser and go to http://127.0.0.1:5000/ or http://localhost:5000/. You should see the "Hello, World!" message.

Congratulations! You've just created a simple Flask app. From here, you can start building more complex applications by defining additional routes, handling form submissions, and connecting to databases.

Remember that this is a basic example, and as your app grows, you may want to structure it differently, use templates for HTML rendering, and add more features based on your requirements. Refer to the Flask documentation for more detailed information and advanced topics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants