开发者

suitable web framework for compositing JSON data in to HTML

I'm looking for a good web framework for compositing multiple JSON sources fetched with HTTP requests in to static HTML. I am not looking to do this on开发者_开发知识库 the client-side (browser, javascript), I am looking for the best server-side solution.

So, what I need to do is:

  • Fetch several different JSON documents over HTTP
  • Format that JSON as HTML content, mostly with templates but some dynamic custom HTML
  • Basic login/logout/preferences customization, nothing major
  • Mostly stateless pages; what state there is, comes already in the JSON
  • User / search engine friendly / bookmarkable URLs; should be customizable accurately

How I'd like to do it:

  • A lean solution, perhaps just a template engine
  • HTML templates that have no custom syntax over HTML/XML, like Wicket and almost like Tapestry
  • Application server that is scalable and utilizes multiple CPUs properly (for example, a single Python process does not)
  • Preferably Java, but if Java doesn't have anything that fits, willing to consider others

As for the template part, if this were to be in JavaScript in the browser, something like PURE would be my tool of choice.


You might want to check out RESTx. That's an open source platform for the easy creation of RESTful resources. It allows you to write custom data access and integration logic in either Java or Python. Getting data from multiple sources and combining them is what it's made for, so this should be a pretty close fit. Data output is rendered according to what the user requested. For example, a further JSON data source, or the same data rendered in HTML.

The HTML rendering is currently according to a built-in template. However, that should be easy enough to modify. I'm one of the developers on that project, so if you need some special template functionality, let me know and I will see what I can do.

To give you an example: Assume you have two JSON resources, in your code you would write this (I'm giving a Python example here, but the Java example would look very similar):

status, data_1 = accessResource("/resource/some_resource")
status, data_2 = accessResource("/resource/some_other_resource")
# data_1 and data_2 now hold a dictionary, list, etc., depending on the JSON
# that was returned.
# ... some code that combines and processes the data and produces a dict or list
# with the result. The data object you return here is then automatically rendered
# in either HTML or JSON, depending on the client request.
return Result.ok(data)

Also take a look at the example for some simple data integration here.


I think that the only framework you need is a library that reads json. The templates can very well be standard jsp pages.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜