librelist archives

« back to archive

basic question

basic question

From:
水静流深
Date:
2014-07-22 @ 05:54
>>> 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 .    
     ‍
 ‍

Re: [flask] basic question

From:
Mohammad Reza Kamalifard
Date:
2014-07-22 @ 06:21
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 .
> ‍
> ‍

回复: [flask] basic question

From:
水静流深
Date:
2014-07-23 @ 02:57
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 .    
     ‍
 ‍

Re: 回复: [flask] basic question

From:
Malviya, Urvi
Date:
2014-07-23 @ 05:20
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.

Re: [flask] basic question

From:
Matt Smith
Date:
2014-07-22 @ 08:07
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 .
> ‍
> ‍