- Flask By Example
- Gareth Dwyer
- 123字
- 2021-07-09 20:06:54
Creating a new Flask application
To begin with, we'll create the skeleton of our new Flask application, which is pretty much the same as our Hello World application. Open headlines.py
in your editor and write the following code:
from flask import Flask app = Flask(__name__) @app.route("/") def get_news(): return "no news is good news" if __name__ == '__main__': app.run(port=5000, debug=True)
This works exactly as before. You can run it in your terminal with python
headlines.py
. Open a browser and navigate to localhost:5000
to see the no news is good news string displayed. However, although the old adage may be true, it's bad news that our app does not do anything more useful than this. Let's make it display actual news to our users.
推薦閱讀
- Visual C++程序設(shè)計學(xué)習(xí)筆記
- 程序員面試白皮書
- 潮流:UI設(shè)計必修課
- 自己動手實現(xiàn)Lua:虛擬機、編譯器和標(biāo)準(zhǔn)庫
- R語言編程指南
- 零基礎(chǔ)學(xué)Java(第4版)
- 深入淺出DPDK
- 微信公眾平臺開發(fā):從零基礎(chǔ)到ThinkPHP5高性能框架實踐
- SQL Server 2016數(shù)據(jù)庫應(yīng)用與開發(fā)習(xí)題解答與上機指導(dǎo)
- 基于Struts、Hibernate、Spring架構(gòu)的Web應(yīng)用開發(fā)
- 詳解MATLAB圖形繪制技術(shù)
- Android傳感器開發(fā)與智能設(shè)備案例實戰(zhàn)
- Arduino計算機視覺編程
- Oracle數(shù)據(jù)庫編程經(jīng)典300例
- Java程序設(shè)計教程