Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/app/app.py
blob: 291b309611b83cc167100a859fdd8f3a314224f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import sys
from flask import flash,Flask,request,url_for,redirect,session
from flaskext.genshi import Genshi, render_response

app = Flask(__name__)
app.debug = True
app.secret_key="ilovesugar"
genshi = Genshi(app)

@app.route('/')
def hello_world():
    flash("Hello World")
    return render_response('hello.html') 

def shutdown_server():
    func = request.environ.get('werkzeug.server.shutdown')
    if func is None:
        raise RuntimeError('Not running with the Werkzeug Server')
    func()

@app.route('/debug')
def debug():
    raise Warning("This is a traceback of the Construct IDE environment. This is what you'll see when there's an error in your program or you manually raise an exception.") 

@app.route('/shutdown')
def shutdown():
    shutdown_server()
    return 'Goodbye'

if __name__=="__main__":
    try:
        port=int(sys.argv[1])
    except IndexError:
        port=5000
        import webbrowser
        webbrowser.open("http://localhost:%s/" % port)
    app.run(port=port) # for local only
    #app.run(host='0.0.0.0', port=port) # open for all