简单有效的网络框架

发布于 2024-08-23 15:27:55 字数 1537 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(12

女皇必胜 2024-08-30 15:27:55

这个问题是基于完全不理解您显然“研究”过的任何工具,或者实际上是一般的网络服务。

Django 有管理面板吗?好吧,如果您不想,请不要使用它。那里不需要进行任何配置,如果需要的话,它可以用于管理您的数据。

PHP有chown问题吗? PHP 是一种语言,而不是一个框架。如果您尝试使用它运行某些内容,则需要适当地设置权限。无论您使用什么语言,情况都是如此。

您想要一些不需要知道其地址或文件位置的东西吗?这到底意味着什么?如果您正在设置网络服务器,它需要知道要响应哪个地址。然后它需要知道要运行哪些代码来响应请求。如果不在某处配置文件的地址和路径,就不会发生任何事情。

This question is based on a complete failure to understand any of the tools you have apparently "investigated", or indeed web serving generally.

Django has an admin panel? Well, don't use it if you don't want to. There's no configuration that needs to be done there, it's for managing your data if you want.

PHP has chown problems? PHP is a language, not a framework. If you try and run something with it, you'll need to set permissions appropriately. This would be the case whatever language you use.

You want something that doesn't need to know its address or where its files are? What does that even mean? If you are setting up a webserver, it needs to know what address to respond to. Then it needs to know what code to run in response to a request. Without configuring somewhere the address and the path to the files, nothing can ever happen.

疏忽 2024-08-30 15:27:55

在 web2py 中,您不需要使用管理界面。它是可选的。
以下是从零开始创建简单应用程序的方法:

 wget http://web2py.com/examples/static/web2py_src.zip
 unzip web2py_src.zip
 cd web2py/applications
 mkdir myapp
 cp -r ../welcome/* ./

可选 编辑您的应用程序

 emacs controllers/default.py 
 emacs models/db.py 
 emacs views/default/index.html
 ...

(您可以删除其中不需要的所有内容)。
现在运行 web2py 并尝试一下

 cd ../..
 python web2py.py -i 127.0.0.1 -p 8000 -a chooseapassword &
 wget http://127.0.0.1:8000/myapp/default/index.html

当你编辑controller/default.py时,你有一个控制器,例如

 def index():
      the_input = request.vars # this is parsed from URL
      return dict(a=3,b=5,c="hello")

你可以返回一个字典(将由与操作同名的视图解析)或一个字符串(实际的页面内容)。例如:

 def index():
      name = request.vars.name or 'anonymous'
      return "hello "+name

调用

 wget http://127.0.0.1:8000/myapp/default/index?name=Max

返回

 'hello Max'

/myapp/default/index?name=Max 调用文件夹 applications/myapp/ 中应用程序的控制器 default.py 的函数索引,并将 name=Max 传递到 request.vars.name='Max '。

In web2py you do not need to use the admin interface. It is optional.
Here is how you create a simple app from zero:

 wget http://web2py.com/examples/static/web2py_src.zip
 unzip web2py_src.zip
 cd web2py/applications
 mkdir myapp
 cp -r ../welcome/* ./

Optional Edit your app

 emacs controllers/default.py 
 emacs models/db.py 
 emacs views/default/index.html
 ...

(you can delete everything in there you do not need).
Now run web2py and try it out

 cd ../..
 python web2py.py -i 127.0.0.1 -p 8000 -a chooseapassword &
 wget http://127.0.0.1:8000/myapp/default/index.html

When you edit controller/default.py you have a controller for example

 def index():
      the_input = request.vars # this is parsed from URL
      return dict(a=3,b=5,c="hello")

You can return a dict (will be parsed by the view with same name as action) or a string (the actual page content). For example:

 def index():
      name = request.vars.name or 'anonymous'
      return "hello "+name

and call

 wget http://127.0.0.1:8000/myapp/default/index?name=Max

returns

 'hello Max'

/myapp/default/index?name=Max calls the function index, of the controller default.py of the application in folder applications/myapp/ and passes name=Max into request.vars.name='Max'.

音栖息无 2024-08-30 15:27:55

我认为你需要更具体地说明你想要实现什么,以及你想要开发什么样的产品。 “无需设置”的产品可能会带来大量的自动配置膨胀,而需要小型设置文件的框架也可以在几分钟内完成设置,从长远来看会更加简单。还总是需要考虑一些安全和访问权限,因为网络是一个开放的地方。

此外,支持 Web 2.0 风格的框架不一定是一个框架。不要放弃好的选择,因为它们也会做你不喜欢或不需要的事情,只要它们允许你在没有它们的情况下工作。

PHP 的 chown 和 chmod 与服务器冲突(代码无法访问上传的文件,反之亦然)并且无法正确处理 url;

PHP 本身并不是一个框架,它是一种编程语言。我不知道您尝试过哪种基于 PHP 的框架或产品,但您描述的所有问题都是可以解决的,而不是 PHP 独有的。如果您喜欢这种语言,也许可以再尝试一次。相关SO问题:

如果您需要某种可以在任何地方运行的东西(即在尽可能多的服务器上) PHP 自然会成为您的首选,因为它在廉价托管可用性方面击败了所有其他平台。

不过,如果我是你,我现在不会限制我的选择太多。例如,我听到了很多关于 Django 的好消息。此外,Google App 引擎是一个有趣的、可扩展的平台网络工作,支持多种语言。

I think you need to be more specific about what you want to achieve, and what kind of product(s) you want to develop. A "no setup required" product may come with tons of auto-configuration bloat, while a framework requiring a small setup file could be set up in minutes, too, with much more simplicity in the long run. There is also always going to be some security and access rights to be taken into consideration, simply because the web is an open place.

Also, a framework supporting Web 2.0ish things doesn't have to be automatically a bad framework. Don't throw away good options because they also do things you don't like or need, as long as they allow you to work without them.

PHP had chown and chmod conflicts with the server (the code couldn't access uploaded files or vice versa) and couldn't handle urls properly;

PHP is not a framework in itself, it's a programming language. I don't know which PHP-based framework or product you tried but all the problems you describe are solvable, and not unique to PHP. If you like the language, maybe give it another shot. Related SO questions:

If you need something that runs everywhere (i.e. on as many servers as possible) PHP will naturally have to be your first choice, simply because it beats every other platform in terms of cheap hosting availability.

If I were you, I wouldn't limit my options that much at this point, though. I hear a lot of good things about Django, for example. Also, the Google App engine is an interesting, scalable platform to do web work with, supporting a number of languages.

七禾 2024-08-30 15:27:55

Werkzeug

import werkzeug

@werkzeug.Request.application
def app(request):
  return werkzeug.Response("Hello, World!")

werkzeug.run_simple("0.0.0.0", 4000, app)

您可以选择使用 werkzeug URL 路由(或您自己的,或任何其他框架中的任何内容)。您可以使用任何您想要的 Python ORM 或模板引擎(包括来自其他 Python 框架的引擎)等。

基本上它只是围绕 WSGI 构建的 RequestResponse 对象以及一些实用程序。 Python 中还有更多类似的库(例如 webobCherryPy)。

Werkzeug:

import werkzeug

@werkzeug.Request.application
def app(request):
  return werkzeug.Response("Hello, World!")

werkzeug.run_simple("0.0.0.0", 4000, app)

You can optionally use werkzeug URL routing (or your own, or anything from any other framework). You can use any ORM or template engine for Python you want (including those from other Python frameworks) etc.

Basically it's just Request and Response objects built around WSGI plus some utilities. There are more similar libraries available in Python (for example webob or CherryPy).

倒数 2024-08-30 15:27:55

我需要的是一种简单有效的跨平台 Web 开发语言,几乎可以在任何地方使用。

你尝试过 HTML 吗?

但说真的,我认为佩卡说得对,他说你需要具体说明并澄清你想要什么。
您不需要的大多数功能都是 Web 应用程序的标准模块(用户和角色管理、数据绑定、持久性、接口)。

我们根据客户要求使用以下任意或组合:perl、PHP、Flash、Moonlight、JSP、JavaScript、Java、(D/X)HTML、zk。

What I need is a simple and effective cross-platform web development language that works pretty much anywhere.

Have you tried HTML?

But seriously, I think Pekka is right when he says you need to specify and clarify what you want.
Most of the features you don't want are standard modules of a web app (user and role mgmt., data binding, persistence, interfaces).

We use any or a mix of the following depending on customer requirements: perl, PHP, Flash, Moonlight, JSP, JavaScript, Java, (D/X)HTML, zk.

淤浪 2024-08-30 15:27:55

我是 python 新手,但拥有 12 年经验丰富的 PHP 开发人员,但我不得不承认,我迁移到 python 是因为 bottle 框架。我是非洲人,所以你不需要特别聪明就能使用它......尝试一下,你会喜欢它的。嘿,它也无需配置即可在 appspot 上运行!

  1. 安装python
  2. 下载bottle.py(单个文件)
  3. 创建< /p>

    #你的文件名:index.py
    从瓶子导入路线,运行
    
    @路线('/')
    定义索引():
        返回'jambo肯尼亚! Hakuna Matata 瓶子。呵呵呵呵'
    run()
  4. 坐下来,喝可可,微笑:)

I am python newbie but experienced PHP developer for 12 years but I have to admit that I migrated to python because of the bottle framework. I am African so you don't have to be extra smart to use it... Give it a try, you'll love it. Hey and it also runs on appspot with no config!

  1. Install python
  2. Download bottle.py (single file)
  3. Create

    #your file name : index.py
    from bottle import route, run
    
    @route('/')
    def index():
        return 'jambo kenya! hakuna matata na bottle. hehehe'
    run()
  4. Sit back, sip cocoa and smile :)
泪冰清 2024-08-30 15:27:55

我想说 Ruby on Rails 正是您所寻找的。随时随地工作,无需配置。您只需安装它,安装您需要的 gem,然后就可以开始了。

我还使用 ColdFusion,它是完全多平台的,但依赖于管理员设置来进行 DSN 配置等。

I'd say Ruby on Rails is what you're looking for. Works anywhere, and no configuration needed. You only have it installed, install the gems you need, and off you go.

I also use ColdFusion, which is totally multi-platform, but relies on the Administrator settings for DSN configuration and stuff.

辞慾 2024-08-30 15:27:55

TurboGears:一切都是可选的。

TurboGears: Everything optional.

我最亲爱的 2024-08-30 15:27:55

尝试bottle。我将它用于简单的网络应用程序。根据我的经验,它非常直观且易于使用。

这是一些示例代码,它只需要 bottle.py,没有其他依赖项。

from bottle import route, run

@route('/')
def index():
    return 'Hello World!'

run(host='localhost', port=8080)

Give bottle a try. I use it for my simple no-frills webapps. It is very intuitive and easy to work with in my experience.

Here is some sample code, and it requires just bottle.py, no other dependencies.

from bottle import route, run

@route('/')
def index():
    return 'Hello World!'

run(host='localhost', port=8080)
最美不过初阳 2024-08-30 15:27:55

最近偶然发现了Quixote。虽然从未使用过它。

Just stumbled upon Quixote recently. Never used it though.

三生池水覆流年 2024-08-30 15:27:55

使用普通的旧式 ASP。 IIS 不关心文件存储在哪里。所有路径都可以相对于虚拟目录进行设置。这意味着您可以包含“/myproject/myfile.asp”,而在 PHP 中通常使用相对路径来完成。 Global.asa 然后包含应用程序的全局配置。您几乎不必担心代码中的相对路径。

在 PHP 中,你会有 include(dirname(FILE) . '/../../myfile.php") 这当然很丑陋。我为此找到的唯一“解决方案”是HTML 文件,然后使用 SSI(包括服务器端)。

ASP 的唯一缺点是可用性,因为它必须在 Windows 上运行,而且无需担心复杂的 Linux 配置。很简单,但您也可以选择编写服务器端 JavaScript,因为您熟悉 C。

Use plain old ASP. IIS does not care where files are stored. All paths can be set relative from the virtual directory. That means you can include "/myproject/myfile.asp", whereas in PHP it's often done using relative paths. Global.asa then contains global configuration for the application. You hardly ever have to worry about relative paths in the code.

In PHP you'd have include(dirname(FILE) . '/../../myfile.php") which is of course fugly. The only 'solution' I found for this is making HTML files and then using SSI (server side includes).

The only downside to ASP is the availability, since it has to run on Windows. But ASP files just run, and there's not complex Linux configuration to worry about. The language VBScript is extremely simple, but you can also choose to write server side JavaScript, since you're familiar with C.

我认为你需要关注 Restful Web 应用程序。 Zend 是一个基于 PHP 的 MVC 框架。

I think you need to focus on Restful web applications. Zend is a PHP based MVC framework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文