Exemple #1
0
    def UP_SERVER(self, PORT, *args, **keyargs):
        #Exemple https://localhost:8000
        httpd = Server(("%s" % c['local_host'], PORT), Handler)
        try:
            print("Start serving at port %i" % PORT)
            httpd.serve_forever()
        except KeyboardInterrupt:
            httpd.server_close()

        httpd.server_close()
def start_server(root_dir):
    # Read port selected by the cloud for our application
    PORT = int(os.getenv('PORT', 8000))
    # Change current directory to avoid exposure of control files
    os.chdir(root_dir + "/static")
    httpd = Server(("", PORT), DownloadZipHandler)
    try:
        print("Start serving at port %i" % PORT)
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
Exemple #3
0
def startServer():
    try:
        from SimpleHTTPServer import SimpleHTTPRequestHandler as Handler
        from SocketServer import TCPServer as Server
    except ImportError:
        from http.server import SimpleHTTPRequestHandler as Handler
        from http.server import HTTPServer as Server

    # Read port selected by the cloud for our application
    PORT = int(os.getenv('PORT', 8000))
    # Change current directory to avoid exposure of control files
    os.chdir(
        'C:\\Users\\nettr\\Dropbox\\Random Projects\\Hackathon\\Flood Nav\\Flood-Nav\\src\\static'
    )

    httpd = Server(("", PORT), Handler)
    try:
        print("Start serving at port %i" % PORT)
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()
Exemple #4
0
  from SimpleHTTPServer import SimpleHTTPRequestHandler as Handler
  from SocketServer import TCPServer as Server
except ImportError:
  from http.server import SimpleHTTPRequestHandler as Handler
  from http.server import HTTPServer as Server
from watson_developer_cloud import LanguageTranslatorV2 as LanguageTranslator

language_translator = LanguageTranslator(
            username="******",
                password="******")
import json
with open('glossary.tmx', 'rb') as training_data:
        custom_model = language_translator.create_model(
                        base_model_id = 'en-es',
                                name = 'custom-english-to-spanish',
                                        forced_glossary = training_data)
            print(json.dumps(custom_model, indent=2))
# Read port selected by the cloud for our application
PORT = int(os.getenv('PORT', 8000))
# Change current directory to avoid exposure of control files
os.chdir('static')

httpd = Server(("", PORT), Handler)
try:
  print("Start serving at port %i" % PORT)
  httpd.serve_forever()
except KeyboardInterrupt:
  pass
httpd.server_close()

Exemple #5
0
def run_server():
    try:
        server = Server()
        server.start()
    except Exception as e:
        print("You have some error: {}".format(e))
''' Starts a simple Python HTTP server to serve static files '''
import os
try:
    from SimpleHTTPServer import SimpleHTTPRequestHandler as Handler
    from SocketServer import TCPServer as Server
except ImportError:
    from http.server import SimpleHTTPRequestHandler as Handler
    from http.server import HTTPServer as Server

# Read port selected by the cloud for our application
PORT = int(os.getenv('PORT', 8000))
# Change current directory to avoid exposure of control files
os.chdir('static')

HTTPD = Server(("", PORT), Handler)
try:
    print "Start serving at port %i" % PORT
    HTTPD.serve_forever()
except KeyboardInterrupt:
    pass
HTTPD.server_close()
Exemple #7
0
        ctype = self.guess_type(path)
        try:
            # Always read in binary mode. Opening files in text mode may cause
            # newline translations, making the actual size of the content
            # transmitted *less* than the content-length!
            f = open(path, 'rb')
        except IOError:
            self.send_error(404, "File not found")
            return None
        self.send_response(200)
        self.send_header("Content-type", ctype)
        fs = os.fstat(f.fileno())
        self.send_header("Content-Length", str(fs[6]))
        self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
        self.send_header("Access-Control-Allow-Origin", "*")
        self.end_headers()

        return f


httpd = Server(("", PORT), CORSHTTPRequestHandler)

# Change current directory to avoid exposure of control files
os.chdir('static')
try:
    print("Start serving at port %i" % PORT)
    httpd.serve_forever()
except KeyboardInterrupt:
    pass
httpd.server_close()
        self._set_headers()
        self.wfile.write("<html><body><h1>POST!</h1></body></html>")
		
		




if __name__ == '__main__':
    # Read port selected by the cloud for our application
    PORT = int(os.getenv('PORT', 8000))

    # start Thread with actual computation 
    thread = Process(target = Processing.start, args = ())
    thread.start()
        
        
    # Change current directory to avoid exposure of control files
    os.chdir('static')

    httpd = Server(("", PORT), Custom_Http)


    try:
      print("Start serving at port %i" % PORT)
      httpd.serve_forever()
    except KeyboardInterrupt:
      pass
    httpd.server_close()
    thread.terminate()