Tuesday 15 June 2010

How should an index.html file be served from Python Pyramid for an AngularJS app? -


I am coming into a single-page application with AngularJS, but instead of using nodes or similar, I use Python The most comfortable the server is. Therefore, I am familiar with Pyramid, I am planning to use the pyramid_rpc module to return JSON items in the customer code. All this is straight forward enough, however, what is the best way to serve the initial index file, which includes the early EngelsJS app of Angular JS? Typically, the stable file is served from the stable directory, but is there a problem with the service from the root to the index.html file? Or should I make a view-callable and '/' route using the html template renderer? It is being said that all the pyramids overkill for such application? Any advice would be great.

If you are planning to return some JSON responses then the pyramid is a great option. But I would not advise to use Pyramid_RPC JSON-RPC is a protocol that is targeted for RPC communication between servers. Direct json responses fit most customers (like a browser), such as a bunch of bus routes In response to the receipts / responses, Jasonan returns the reactions. To prevent the client from requesting that page frequently, it is a good place to serve index.html , possibly a good http_cache parameter (of course you can You can go ahead to customize this route, but you should save it later). Config.add_route ('api.users',' / api / Users') config.add_route ('api.user_by_id', ' @view_config (path_name = 'index', renderer = 'map: templates / index.html', http_cache = 3600 * 24 * 365) def index_view (request): return {} @view_config (Path_name = 'API user', request _Marie = 'post', renderer = 'jason') def create_user_view (requested): # Create a user through the request. POST parameter ('userid': user.id,} @view_config (route_name = 'API', request_mate = 'GET', renderer = 'Jason') Return DRU user_info_view (request): userid = request.matchdict ['userid '] #Lookup user returns {' name ': user.name,}

No comments:

Post a Comment