hello world

从0到1,Python Web开发的进击之路

痞子三分冷 提交于 2019-12-04 00:44:58
本文将以个人(开发)的角度,讲述如何从零开始,编写、搭建和部署一个基于Python的Web应用程序。 从最简单的出发点来剖析,一个web应用后端要完成的工作抽象出来无非就是3点: 接收和解析请求。 处理业务逻辑。 生产和返回响应。 对于初学者来说,我们关心的只需这些步骤就够了。要检验这三个步骤,最简单的方法是先写出一个hello world。 request->"hello world"->response python有许多流行的web框架,我们该如何选择呢?试着考虑三个因素: 易用:该框架是面对初学者友好的,而且具有健全的文档,灵活开发部署。例如flask,bottle。 效率:该框架适合快速开发,拥有丰富的轮子,注重开发效率。例如django。 性能:该框架能承载更大的请求压力,提高吞吐量。例如falcon,tornado,aiohttp,sanic。 根据场景使用合适的框架能少走许多弯路,当然,你还能自己写一个框架,这个下面再说。 对于缺乏经验的人来说,易用性无疑是排在第一位的,推荐用flask作为python web入门的第一个框架,另外也推荐django。 首先用virtualenv创建python的应用环境,为什么用virtualenv呢,virtualenv能创建一个纯净独立的python环境,避免污染全局环境。(顺便安利kennethreitz大神的 pipenv

Linux高级命令 ==> find、grep、sed、awk

邮差的信 提交于 2019-12-03 20:31:27
一、find   find命令用来在指定目录下查找文件。如果使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目录与文件。并且将查找到的子目录和文件全部进行显示。 语法 find path -option [ -print ] [ -exec -ok command ] {} \; 常用选项: -name   查找根目录及其子目录下所有以 log 结尾的文件,文件名区分大小写,例如:find / -name '*logf' -iname 查找当前目录及其子目录下所有文件名为 test 的文件,文件名不区分大小写,例如:find . -name test -user    查找文件所属用户为 mysql 的所有文件,例如:find . -user mysql -group 查找文件所属组为 git 的所有文件,例如:find . -group git -type    根据类型查找:如下 f    文件        find . -type f d   目录        find . -type d c   字符设备文件    find . -type c b   块设备文件     find . -type b l    链接文件      find . -type l p   管道文件      find . -type p -size   根据文件大小查询

docker容器的安装与使用

≡放荡痞女 提交于 2019-12-03 20:30:06
------------恢复内容开始------------ 什么是Docker:   docker是一个开源的应用容器引擎,是基于go语言并遵循人Apache2.0协议开源。   docker容器是完全使用沙箱制,相互之间不会有任何接口,(类似ipone的app),更重要的是容器性能开销极低 docker的应用场景:   web应用的自动化打包与发布   自动化测试和持续集成,发布   在服务型环境中部署和调整数据库或其他的后台应用   从头编译或者拓展现有的Openshift或cloud Foundry 平台来搭建自己的PaaS环境 docker的优点:   用于开发,交付和运行应用程序的开放平台,docker能够将应用程序与基础架构分开,从而可以快速交付软件。借助docker可以管理应用程序相同的方式来管理基础架构。通过利用docker的方法来快速交付,测试和部署代码,可以大大减少编写代码和生产环境的中运行代码之间的延迟   1. 快速,一致地交付应用程序   2.响应式部署和扩展   3.在同一硬件上运行更多工作负载 docker的安装:(Ubuntu下) 如果有旧版本的docker,请先卸载后再执行安装命令   卸载指令: sudo apt-get remove docker docker-engine docker.io containerd runc View

Go语言入门:Hello world

笑着哭i 提交于 2019-12-03 15:32:13
本文是「vangoleo的Go语言学习笔记」系列文章之一。 官网: http://www.vangoleo.com/go/go-hello-world/ 在上一篇文章 你好,Go语言 中,我们对Go语言的历史和特点有了认识。接下来,我们就正式进入Go的学习了。 按照大部分编程语言的惯例,我们以经典的“Hello World”开始Go语言的学习之旅。 经典的“Hello World”案例来自于1978年出版的C语言圣经 。很巧合的是该书的作者Brian W. Kernighan也是《Go语言圣经》一书的作者。 本教程中,我会使用最方便的方式Golang Playground来体验Go语言。在浏览器中打开 https://play.golang.org ,在页面直接编写Go代码,并运行。使用Golang Playground无需安装Go,无需配置Golang的开发环境(比如环境变量),无需安装文本编辑器或IDE。 大部分的Hello World教程都会从如何安装Go,配置环境变量等开始。但是Go语言的安装和开发环境配置其实是一个比较复杂的话题。我希望在大家刚接触Go语言时,能对go语言有一个快速,直观的认识。而不要陷入如何配置Go的开发环境。配置Go的开发环境涉及到Go语言的另外两个概念:GOPATH和Go module。而这又会牵扯到Go语言混乱、悠久的依赖管理发展史

[Zephir官方文档翻译之五] 入门指导

别来无恙 提交于 2019-12-03 14:31:02
入门指导 Zephir还有这本手册,是为了PHP开发者想开发C扩展并降低复杂度面打算的。 我们假设你有编程语言的基础。我们会在介绍的时候尽可能的向PHP,C,Javascript等语言的特点来陈述。 如果你懂得这些语言中的某一种的话,我们会指出它们来Zephir的相似点。当然其它的一些Zephir的新特性还有 不同点我们也会一一介绍。 检测安装情况 如果你成功的安装了Zephir,你可以在命令行中执行下面的命令: $ zephir help 如果安装正确的话,你会看到下面的提示: _____ __ _ /__ / ___ ____ / /_ (_)____ / / / _ \/ __ \/ __ \/ / ___/ / /__/ __/ /_/ / / / / / / /____/\___/ .___/_/ /_/_/_/ /_/ Zephir version 0.4.5a Usage: command [options]Available commands: build Generate/Compile/Install a Zephir extension clean Cleans the generated object files in compilation compile Compile a Zephir extension full-clean Cleans the

What's the difference between NSString *s = @“string” and NSString *s = [[NSString alloc] initWithString:@“string”]?

匿名 (未验证) 提交于 2019-12-03 09:13:36
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I think the question is clear enough but still - what's the difference between: NSString *string = @"Hello world!"; and NSString *string = [[NSString alloc] initWithString:@"Hello world!"]; Let me know if this already answers it. 回答1: NSString *string = [[NSString alloc] initWithString:@"Hello world!"]; Per cocoa as cocoa naming convention, You create an object using a method whose name begins with “alloc”, “new”, “copy”, or “mutableCopy”. That means you own the string above, hence you're responsible to release the object. NSString *string =

Python ― return, return None, and no return at all

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Consider three functions: def my_func1(): print "Hello World" return None def my_func2(): print "Hello World" return def my_func3(): print "Hello World" They all appear to return None. Are there any differences between how the returned value of these functions behave? Are there any reasons to prefer one versus the other? 回答1: On the actual behavior, there is no difference. They all return None and that's it. However, there is a time and place for all of these. The following instructions are basically how the different methods should be used

How to run a hello.js file in Node.js on windows?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to run a hello world program written in javascript in a separate file named hello.js Currently running windows version of node.js. The code runs perfectly in console window but how do I reference the path in windows environment . C:\abc\zyx\hello.js in Unix I guess it is showing $ node hello.js I'm absolutely new to Node.js Please correct me if I am doing something wrong. I tried > node C:\abc\zyx\hello.js ----didn't work > C:\abc\zyx\hello.js --didn't work UPDATE1: Added node.exe to the folder where hello.js file is sitting.

Python核心技术与实战 笔记

独自空忆成欢 提交于 2019-12-03 06:30:24
基础篇 Jupyter Notebook 优点 整合所有的资源 交互性编程体验 零成本重现结果 实践站点 Jupyter 官方 Google Research 提供的 Colab 环境 安装 运行 列表与元组 列表和元组,都是 一个可以放置任意数据类型的有序集合。 l = [1, 2, 'hello', 'world'] # 列表中同时含有 int 和 string 类型的元素 l [1, 2, 'hello', 'world'] tup = ('jason', 22) # 元组中同时含有 int 和 string 类型的元素 tup ('jason', 22) 列表是动态的,长度大小不固定,可以随意地增加、删减或者改变元素 (mutable) 元组是静态的,场地大小固定,无法增加删除或者改变 (immutable) 都支持负数索引; 都支持切片操作; 都可以随意嵌套; 两者可以通过 list() 和 tuple() 函数相互转换; 列表和元组存储方式的差异 由于列表是动态的,所以它需要存储指针,来指向对应的元素。增加/删除的时间复杂度均为 O(1)。 l = [] l.__sizeof__() // 空列表的存储空间为 40 字节 40 l.append(1) l.__sizeof__() 72 // 加入了元素 1 之后,列表为其分配了可以存储 4 个元素的空间 (72 -

How to produce a minimal BIOS hello world boot sector with GCC that works from a USB stick on real hardware?

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have managed to produce a minimal boot sector that works with QEMU 2.0.0 Ubuntu 14.04: .code16 .global _start _start: cli mov $msg, %si mov $0x0e, %ah loop: lodsb or %al, %al jz halt int $0x10 jmp loop halt: hlt msg: .asciz "hello world" .org 510 .word 0xaa55 Compiled with: as -o main.o main.S ld --oformat binary -o main.img -Ttext 0x7C00 main.o The example is available on this repo: https://github.com/cirosantilli/x86-bare-metal-examples/tree/2b79ac21df801fbf4619d009411be6b9cd10e6e0/no-ld-script Upon: qemu -hda main.img it shows hello