Esempio n. 1
0
from os import environ
from settings.settings import settings
from modules.HttpServer import HttpServer
from modules.WebManager import WebManager

http_server = HttpServer(environ, sys.stdin)
web_manager = WebManager(http_server, None)

template_folder = 'templates'


def fetch_template(template_file):
    template_loader = FileSystemLoader(template_folder)
    env = Environment(loader=template_loader,
                      autoescape=select_autoescape(['html', 'xml']))
    template = env.get_template(template_file)
    return template


def handle_get(http_server, database_manager, session, account):
    template = fetch_template("pricing.jinja.htm")
    keys = {}
    output = template.render(keys)
    http_server.print_headers()
    print(output)


web_manager.set_method_callback(WebManager.HTTP_METHOD_GET, handle_get)

web_manager.run()
Esempio n. 2
0
    http_server.print_headers()
    print(
        "<!DOCTYPE html><html><meta http-equiv=\"refresh\" content=\"0;URL='/account/signin?"
        + query + "'\" /><head></head></html>")


def redirect_to_phone_confirmation(http_server, database_manager, session,
                                   account):
    query = urlencode(
        {"redirect": http_server.get_request_header("REQUEST_URI")},
        quote_via=quote_plus)
    http_server.set_status(307)
    #http_server.set_header("Location", redirect_location)
    http_server.print_headers()
    print(
        "<!DOCTYPE html><html><meta http-equiv=\"refresh\" content=\"0;URL='/account/confirm_phone?"
        + query + "'\" /><head></head></html>")


web_manager.set_method_callback(WebManager.HTTP_METHOD_GET, handle_get)

web_manager.set_method_callback(WebManager.HTTP_METHOD_POST, handle_put_post)

web_manager.set_method_callback(WebManager.HTTP_METHOD_PUT, handle_put_post)

if web_manager.is_logged_in() is False:
    handle_unauthorized(http_server, database_manager, web_manager.session,
                        web_manager.account)
else:
    web_manager.run()