Beispiel #1
0
def handle(req):
    req.content_type = req.headers_out['Content-Type'] = 'text/html'
    cfg = config.Config('/data/pypi/config.ini')
    request = RequestWrapper(cfg, req)
    pseudoenv = {}
    pseudoenv['CONTENT_TYPE'] = req.headers_in.get('content-type', '')
    pseudoenv['REMOTE_ADDR'] = req.get_remote_host(apache.REMOTE_NOLOOKUP)
    pseudoenv['HTTP_USER_AGENT'] = req.headers_in.get('user-agent', '')
    pseudoenv['QUERY_STRING'] = req.args
    pseudoenv['HTTP_CGI_AUTHORIZATION'] = req.headers_in.get('authorization',
        '')
    pseudoenv['REQUEST_METHOD'] = req.method
    path_info = req.path_info
    pseudoenv['PATH_INFO'] = path_info
    try:
        handler = WebUI(request, pseudoenv)
        handler.run()
    except:
        s = StringIO.StringIO()
        traceback.print_exc(None, s)
        req.write("<pre>")
        req.write(cgi.escape(s.getvalue()))
        req.write("</pre>")
        req.headers_out['Content-Type'] = 'text/html'
    req.content_type = req.headers_out['Content-Type']
    return apache.OK
Beispiel #2
0
@app.route('/stop')
def stop():
    print("Stopping...")
    MainLoop.flag = False
    return ""


@app.route('/background_process')
def background_process():
    MainLoop.runMain()
    MainLoop.flag = True
    return ""


@app.route("/get_game/<name>")
def get_game(name):
    FetchFromTwitch.set_current_game(name)
    FetchDataIngame.set_current_game_frame(name)
    return "nothing"


@app.route("/new_stream", methods=["GET"])
def new_stream():
    if len(MainLoop.streamerQue) != 0:
        return MainLoop.streamerQue.pop()
    return ""


if __name__ == "__main__":
    ui.run()
    #app.run(debug=True)
Beispiel #3
0
from flask import Flask, render_template, request
from webui import WebUI

import os

app = Flask(__name__)
ui = WebUI(app, debug=True)

@app.route('/')
def main():
  return "Hello world!"

if __name__ == '__main__':
  ui.run()