vendredi 3 avril 2015

How can I integrate Ember.js with my own http server?

I'm writing my own HTTP server which handles the request and returns the html pages to the user. I want to integrate with Ember.js, in other words, I want to return html pages with ember code. However, the ember template is not being processed as you can see in the image above.


enter image description here


HTTP server for understanding



#!/usr/bin/python
# -*- coding: utf-8 -*-

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from os import curdir, sep

PORT_NUMBER = 8080


# This class will handles any incoming request from
# the browser

class myHandler(BaseHTTPRequestHandler):

# Handler for the GET requests

def do_GET(self):
if self.path == '/':
self.path = '/index_example2.html'

try:
# Open the static file requested and send it

f = open(curdir + sep + self.path)
self.send_response(200)
self.send_header('Content-type', mimetype)
self.end_headers()
self.wfile.write(f.read())
f.close()
return
except IOError:

self.send_error(404, 'File Not Found: %s' % self.path)


try:

# Create a web server and define the handler to manage the
# incoming request

server = HTTPServer(('', PORT_NUMBER), myHandler)
print 'Started httpserver on port ', PORT_NUMBER

# Wait forever for incoming htto requests

server.serve_forever()
except KeyboardInterrupt:

print '^C received, shutting down the web server'
server.socket.close()


How can I integrate Ember.js with my own http server?





Aucun commentaire:

Enregistrer un commentaire