大学回想曲三——web开发

本文介绍了Mongoose Web服务器的特点及其使用方法,并对比了使用Python搭建简易Web服务器的方式,包括利用SimpleHTTPServer模块和Django框架等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

突然间让我想起了,首页中的description,一个有趣而又有意思的简介。

 

"Phodal's博客,个人博客用于软件开发心得分享及SEO优化学习,博客内容主要以计算机方面为主,Powered by Django and Python。狼和凤凰一起追逐龙,龙消失了。。。"

硬盘中有太多关于web开发的资料,以及一些开发过的CMS。在新的硬盘用满一年之际,换了一个固态硬盘,新的硬盘上面已经没有太多的东西。主要还是旧的,用了三年,还算是有些东西,淘一淘还真有不少的东西。如mongoose

Mongoose Web Server

Mongoose简介

 

Mongoose Web Server是一款易于使用的Web服务器,它可以嵌入到其它应用程序中,为其提供Web接口。

当然原文是这么介绍的。

 

Mongoose is the most easy to use web server on the planet. A web server of choice for Web developers (PHP, Ruby, Python, etc) and Web designers.

 

Mongoose is built on top of libmongoose embedded library, which can turn anything into a web server in 5 minutes worth of effort and few lines of code. Libmongoose is used to serve Web GUI on embedded devices, implement RESTful services, RPC frameworks (e.g. JSON-RPC), handle telemetry data exchange, and perform many other tasks in various different industries including aerospace, manufacturing, finance, research, automotive, gaming, IT.

Mongoose是建立在libmongoose嵌入式库之上的,它可以在5分钟内值得的努力和几行代码把任何东西到Web服务器。 Libmongoose是用来提供Web的GUI在嵌入式设备上,实现RESTful服务,RPC框架(如JSON-RPC),处理遥测数据交换,并在各个不同的行业,包括航空航天,制造业,金融,科研,汽车,游戏执行许多其他任务,IT。

简单的一个示例便是我们有需要在内网传一个文件,如某个目录下,那么我们只需要

  cd /path 
  mongoose

这样的话,便会建立一个简单的web服务器,别人也只需要访问你的IP:8080即可。如,192.168.1.1:8080。

当然他提供的版本有Linux、Windows以及Mac OS。记得以前我写东西的时候,都是只写Linux和Windows,现在又要加上Mac OS了。

Python

Python Web Server

当然我们也可以用python来解决上面的问题

  python -m SimpleHTTPServer

如果要加上端口号便是

 python -m SimpleHTTPServer 8080

Django

作为一直在用的框架,Django算是最好的,只是一直很少在后台玩,一直在前端开发。安装玩Django后,便是

   django-admin.py startproject project

去创建一个项目,总得来说没有Ruby On Rails来得方便,但是Rails的生成,总会让人觉得生成得越多,便越难改。只能说各有各的好处吧。

Python的web框架还有很多,如CherryPy,Tornado,web.py*。

CherryPy的hello,world便是

import cherrypy
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True

cherrypy.quickstart(HelloWorld())

Nginx header修改

  1. 看到知乎修改了自己的Server header,于是有一次也就修改了自己的。

    vim src/http/ngx_http_header_filter_module.c

默默地将其中的这一行

  static char ngx_http_server_string[] = "Server: nginx" CRLF;

改成了

 static char ngx_http_server_string[] = "Server: phodal" CRLF;

2.另外一个便是nginx.h

 vim src/core/nginx.h

修改

  #define NGINX_VERSION      "0.11"

  #define NGINX_VER          "phodal/" NGINX_VERSION

3.编译

./configure --user=www --group=www --add-module=../nginx-static-etags --add-module=../ngx_pagespeed-1.7.30.4-beta --add-module=../ngx_cache_purge --prefix=/usr/local/nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6

4.安装

make
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
cp objs/nginx /usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx -t
make upgrade
echo "Upgrade completed!"
echo "Program will display Nginx Version......"

5.查看

/usr/local/nginx/sbin/nginx -v

于是

nginx version: phodal/0.11.0

原文大学回想曲三——web开发 
这样我们就可以继续玩耍了~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值