5

许多语言都有用于编写非常小的网站或 Web 服务的微框架,例如用于 Python 的 Flask 或用于 Ruby 的 Sinatra。在 Squeak 上,似乎没有任何等价物。Iliad、Seaside 和 AIDA 都非常重,因为只是有一点服务。实现此目的的首选方法是什么?直接将处理程序注入 Comanche 或 Swazoo?

4

4 回答 4

6

“在这种特殊情况下,我确实有三个 URL 需要通过 HTTP POST 执行操作;就是这样。”

对于非常简单的情况,您可以像这样注册(或子类)Kom 的 HttpService(来自类注释,请参阅更多信息/选项):

    (HttpService on: 8080 named: 'Example Http Service')
    onRequestDo: [ :httpRequest | SomeGlobal processRequest: httpRequest ];
    start
于 2010-12-22T22:01:48.550 回答
5

您也可以使用茶壶。Teapot 是基于 Zinc HTTP 组件的微型 Web 框架,专注于简单性和易用性。它不到 500 行代码,不包括测试。

Teapot on
    GET: '/hi' -> 'Bonjour!';
    GET: '/hi/<user>' -> [:req | 'Hello ', (req at: #user)];
    GET: '/say/hi/*' -> (Send message: #greet: to: greeter);
    start.

(ZnEasy get: 'http://localhost:1701/hi/user1') entity string. "Hello user1"

在过滤器之前有可用的胡子模板、输出变压器。该框架有据可查。

于 2014-12-01T05:30:46.400 回答
3

I would like to share what I think is more up-to-date information (as of end of 2012).

Zinc Components

Currently in Pharo 1.4/2.0 the de-facto standard for HTTP client/server seems to be the Zinc HTTP Components. And the latest Seaside version (3.0) switched to Zinc as well.

You can of course use Zinc directly to implement web-services or serve web-pages.

Take a look particularly at classes ZnServer and search for classes like Zn*Delegate (like ZnDefaultServerDelegate or ZnStaticFileServerDelegate)

Seaside REST

Latest versions of Seaside include support for RESTful web-services. This can be used to implement web-services or serve web-pages. It's pretty straightforward.

For more information look at the "REST Services" chapter of the online Seaside book. This chapter centers about implementing web-services, but it works for web-pages as well.

Ratpack

I have also been told about Ratpack, a sinatra-like web-framework developed by Tim Felgentreff. There are two repositories. I think the github one is more recent. See here:

This information comes from a similar question I posted recently.

于 2012-12-03T21:03:17.513 回答
2

您可以在 Swazoo 中为这样的微型网站子类化 SwazooSite,但我认为您很快就会不再需要更多功能,因此从长远来看,直接从这三个框架之一开始是更好的选择。

它们很重可能只是一种印象,并且缺乏更好的此类简单网站的使用文档。此外,如果您将框架视为黑盒,内部复杂但外部简单,那么我会说所有 Smalltalk Web 框架与其他 Web 框架相比都非常简单。

于 2010-12-22T20:37:14.173 回答