10 Learning Flask: Your first web application

 

In this chapter

  • Erik creates his first simple web application
  • Simon explains what Flask is and how it works
  • Emily and Erik work on a web form
  • The first coffee shop web-based menu is ready!

“You said you wanted to create a web application?” Simon asked Erik the next week.

“Yes, sure!” Erik said. “Otherwise, how could I use my program on my iPad?”

“Okay, but be prepared: it’s not an easy task. It will require all your attention. If you don’t completely understand everything we do here, don’t worry. I’ll help you when you need it.”

“I know—you’re a good brother,” Erik said. There was almost no irony in the way he said it.

“We’ll use our good friend, the Mu editor, for our web application. It has a special mode for that. Start the editor and click Mode in the top-left corner.”

Erik did and saw a menu.

“Scroll to the bottom,” Simon said. “Find the Web mode and click it. Then click OK.”

After Erik did that, Simon pointed to the bottom-right corner and said, “See this word ‘Web’ next to the cogwheel? That shows we’ve switched to Web mode. Now let’s see what we can do with it—click New.”

Erik did, and Python code immediately appeared in the editor window.

“Interesting,” he said. “Mu already wrote something for me. Can I run it?”

“Sure, go ahead. First, you’ll have to save it. Call it first_app.py.”

Erik clicked Run and entered first_app.py in the Save dialog. He saw the output at the bottom of the window.

“What is that?” he asked.

New things you have learned today

sitemap