Answer the question
In order to leave comments, you need to log in
How to set up a server in the cloud in Python?
Run this server on localhost
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
class HttpProcessor(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('content-type','text/html')
self.end_headers()
self.wfile.write("hello!")
serv = HTTPServer(("localhost",80),HttpProcessor)
serv.serve_forever()
Answer the question
In order to leave comments, you need to log in
Create a project:
Create a "Connection" (there are different options, I chose "Container" for demonstration):
After creation, information on the container will appear, where links are indicated on which your application will be available:
Create a file "File" -> "New File" (there is option to "drag and drop" the file from your PC). We paste your code:
Correct (instead of "localhost" we write "0.0.0.0" and select a port from the range 1024-9999):
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
class HttpProcessor(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('content-type','text/html')
self.end_headers()
self.wfile.write("hello!")
serv = HTTPServer(("0.0.0.0",8080),HttpProcessor)
serv.serve_forever()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question