>>> from flask import Flask >>> app = Flask(__name__) >>> @app.route('/')
... def index(): ... return '<h1>Hello World!</h1>' ... >>> >>>
app.run(debug=True) * Running on http:// :5000/ * Restarting with
reloader d:\Python34\python.exe: can't find '__main__' module in ''
Conclusion 1:
The app in flask can not be run interactively.
When i change the code into the following and save it as test.py.
from flask import Flask app = Flask(__name__) @app.route('/') def
test_name(): return '<h1>Hello World!</h1>' if __name__=="__main__":
app.run(debug=True)
python test.py can work successfully.
Conclusin 2:
the name of method decorated by app.route can be anything .
Are you using sublime text ? On Tue, Jul 22, 2014 at 10:24 AM, 水静流深 <1248283536@qq.com> wrote: > > >>> from flask import Flask>>> app = Flask(__name__)>>> @app.route('/')... def index():... return '<h1>Hello World!</h1>'...>>>>>> app.run(debug=True) > * Running on http:// :5000/* Restarting with reloader > d:\Python34\python.exe: can't find '__main__' module in '' > > Conclusion 1: > The app in flask can not be run interactively. > > When i change the code into the following and save it as test.py. > > from flask import Flask > app = Flask(__name__) @app.route('/')def test_name(): > return '<h1>Hello World!</h1>' > if __name__=="__main__": > app.run(debug=True) > > python test.py can work successfully. > Conclusin 2: > the name of method decorated by app.route can be anything . > >
no ,run it in python console interactively. ------------------ 原始邮件 ------------------ 发件人: "Mohammad Reza Kamalifard";<mr.kamalifard@gmail.com>; 发送时间: 2014年7月22日(星期二) 下午2:51 收件人: "flask"<flask@librelist.com>; 主题: Re: [flask] basic question Are you using sublime text ? On Tue, Jul 22, 2014 at 10:24 AM, 水静流深 <1248283536@qq.com> wrote: >>> from flask import Flask >>> app = Flask(__name__) >>> @app.route('/') ... def index(): ... return '<h1>Hello World!</h1>' ... >>> >>> app.run(debug=True) * Running on http:// :5000/ * Restarting with reloader d:\Python34\python.exe: can't find '__main__' module in '' Conclusion 1: The app in flask can not be run interactively. When i change the code into the following and save it as test.py. from flask import Flask app = Flask(__name__) @app.route('/') def test_name(): return '<h1>Hello World!</h1>' if __name__=="__main__": app.run(debug=True) python test.py can work successfully. Conclusin 2: the name of method decorated by app.route can be anything .
Hey I m not using sublime text , using gedit in Ubuntu. Plus , I didn’t get you that how is this the solution to my problem.
The name can be anything, but it changes what you reference in url_for() *Regards,* *Matt Smith*Summoner: *PsyKzz* | *@**PsyKzz* On 22 July 2014 06:54, 水静流深 <1248283536@qq.com> wrote: > > >>> from flask import Flask>>> app = Flask(__name__)>>> @app.route('/')... def index():... return '<h1>Hello World!</h1>'...>>>>>> app.run(debug=True) > * Running on http:// :5000/* Restarting with reloader > d:\Python34\python.exe: can't find '__main__' module in '' > > Conclusion 1: > The app in flask can not be run interactively. > > When i change the code into the following and save it as test.py. > > from flask import Flask > app = Flask(__name__) @app.route('/')def test_name(): > return '<h1>Hello World!</h1>' > if __name__=="__main__": > app.run(debug=True) > > python test.py can work successfully. > Conclusin 2: > the name of method decorated by app.route can be anything . > >