From ecaba7d4fe1f94bfa902c797c3eb9d87a80c366a Mon Sep 17 00:00:00 2001 From: Valtyr Farshield Date: Fri, 4 Mar 2016 23:33:35 +0200 Subject: [PATCH] Workaround: HTML embedded into python (useful for generating standalone executables) --- src/pathfinder/model/crest/server.html | 43 --------------------- src/pathfinder/model/crest/server.py | 53 +++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 src/pathfinder/model/crest/server.html diff --git a/src/pathfinder/model/crest/server.html b/src/pathfinder/model/crest/server.html deleted file mode 100644 index 10e343a..0000000 --- a/src/pathfinder/model/crest/server.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - Pathfinder Local Server - - - - - -
-

Pathfinder

-
-

If you see this message then it means you should be logged in with CREST. You may close this window and return to the application.

-
-
- - - diff --git a/src/pathfinder/model/crest/server.py b/src/pathfinder/model/crest/server.py index 92707ae..6117a11 100644 --- a/src/pathfinder/model/crest/server.py +++ b/src/pathfinder/model/crest/server.py @@ -1,6 +1,5 @@ # server.py -import os import BaseHTTPServer import urlparse import socket @@ -8,6 +7,53 @@ import logging +HTML = ''' + + + + + + Pathfinder Local Server + + + + + +
+

Pathfinder

+
+

If you see this message then it means you should be logged in with CREST. You may close this window and return to the application.

+
+
+ + + +''' + + # Reference: https://github.com/fuzzysteve/CREST-Market-Downloader/ class AuthHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self): @@ -17,10 +63,7 @@ def do_GET(self): parts = urlparse.parse_qs(parsed_path.query) self.send_response(200) self.end_headers() - script_dir = os.path.dirname(__file__) - file_path = os.path.join(script_dir, 'server.html') - with open(file_path) as html_file: - self.wfile.write(html_file.read()) + self.wfile.write(HTML) self.server.callback(parts) def log_message(self, format, *args):