# encoding=utf-8

from flask import Flask
from flask import request
import requests
import subprocess
import sys

reload(sys)
sys.setdefaultencoding('utf-8')

app = Flask(__name__)
app.debug = True
app.use_debugger = True

@app.route("/")
def index():
    req = requests.get('http://git.xici.com/api/v3/projects/chekun%2fflask-dances-with-gitlab/repository/branches?private_token=xxx')
    result = req.json()
    options = [u'<option value="%s">%s</option>' % (branch['name'], branch['name']) for branch in result]
    return u'''
    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>Preview 分支管理</title>
        </head>
        <body>
            <h3>Preview 分支管理</h3>
            <form method="post" action="/checkout" charset="utf-8">
                <p>
Example #2
0
    set_verbose(verbose_opt)
    if dry_run_opt:
        msgs.append("Dry run for operation {} on site {}".format(operation.name, site.name))
    else:
        std_str = StringIO.StringIO()
        with stdout_redirector(std_str):
            operation.do_cmd()
            msg = cgi.escape(std_str.getvalue()).replace("\n", "<br>")
            msg = Markup("<code>" + msg + "</code>")
            msgs.append(msg)
            std_str.close()
    return {"msgs": msgs}


if __name__ == "__main__":
    try:
        config_file = file("config.yaml", "r")
        config = yaml.load(config_file)
        if config["FLASK"]["DEBUG"]:
            app.debug = True
            use_debugger = True
            try:
                use_debugger = not (config["FLASK"]["DEBUG_WITH_ECLIPSE"])
                app.use_debugger = use_debugger
                app.use_reloader = use_debugger
            except:
                pass
    except:
        print "Problem openning config.yaml"
    print app
    app.run(host="0.0.0.0")