언어 설정

Menu
Sites
Language
Create a web app with Python

Creating a python for web development can be done using a web framework. Here's an example of how to create a basic web app with the Flask web framework:

 

  1. Install Flask by running pip install Flask in your terminal.
  2. Create a new file called app.py and add the following code:

 

from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World!'

This code creates a Flask application and defines a route that returns a "Hello, World!" message.
3. Run the app by executing python app.py in your terminal. You should see output similar to the following:

Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

4. Open your web browser and navigate to http://localhost:5000/. You should see the "Hello, World!" message in your browser.

 

That's it! You've just created a simple web app using Flask and Python. You can build on this basic structure from here by adding additional routes, templates, and functionality to create a more complex web app.

 

Edited by: Minseok Jang on 08 5월, 2023