最も単純で最も暴力的なウェブサイトと竜巻戦闘を書きます

その理由は、フラスコが、これは最も簡単なWebページの一つで最も暴力的、無内容であることを覚えているの感触に使用されるか、またはDjongo、トルネード(面白い)を初めて目に精通していません。

環境
Win10 
のPython 3.6
PyCharm
トルネード

まず、あなたは計画が必要
最初に関係なく、どのようなプログラミングは、その後、関係なく、我々は正式に、少なくとも、計画を持っている必要がありませんか、と私の計画はには比較的簡単です:

**开发个人日记**
    -- 新建日记
        --保存在数据库
            --信息:
                    1.日期
                    2.天气
                    3.心情
                    4.内容
                    --扩展//未开发
                    5.信纸
                    6.类别
                    7.bgm
    -- 查询日记
        --查询
            --时间
            --心情
            --天气


だから今、私たちはどのようにそれを達成するために、アウトラインを開発するためにダウンしていますか?

[Input]: If i need Python基础 and web前端基础 and 服务器编程基础?
[Output]: Yes…
[Output]: But,it is so f**king EZ.

スタートのHelloWorldから
Hello Worldの、どのように簡単な操作:
私たちのPycharmを開いて、新しいプロジェクトを作成し、我々は(暴力の、プロジェクト名が変更されていないため)のHelloWorldは彼を呼んで
新しいapp.pyを作成します

その後、我々は我々の竜巻ライブラリをインポートする必要がありますが、我々はこれを当分の間、何を必要としません。

from tornado import web,ioloop,httpserver


今回は無力ではありません

何も[李チョウMOzhǎn]ですか
キャスト:開発;ここで、トリック:チップを。また、ちょっとしたトリックを果たしていない、私はそのように考えることができませんでした。レイズ:計画、戦略、展示会:ディスプレイを。また、ちょっとしたトリックを果たしていない、私はそのように考えることができませんでした。レイズ:計画、戦略、展示会:ディスプレイを。また、ちょっとしたトリックを果たしていない、私はそのように考えることができませんでした。
ソースソースソース
清⋅ホンコン・シャングレン「ピーチブロッサムファン」:「夏関史可法;日経わずかプレーンズ、実際に何もしない。」清ホンコン・シャングレン「ピーチブロッサムファン」:「夏関史可法;日経わずかプレーンズ、実際には何もしません。」清⋅ホンコン・シャングレン「ピーチブロッサムファン」:「夏関史可法;日経わずかプレーンズ、実際に何もしない。」
例例例
複雑な数学の問題に直面して1、彼という-私はどこから始めれば分かりません。1.このパス複雑な数学の問題の顔は、彼は-開始する場所を私は知りません。1.このパス複雑な数学の問題の顔は、彼は-開始する場所を私は知りません。私は学習での学習のエディターズチョイスPythonの学校の友人勉強する方法がわからない混乱してありますqun 315 -346- 913は一緒に一緒にと進歩を学ぶことを学ぶことができますが!無料動画を共有

英語は時間のインスピレーションであるなぜ我々が知らない場合には、私たちが書いたものでしょうか?上のWebアプリケーション、!彼の英語それですか?我々がしようとしない理由は、Webアプリケーションは、その後、竜巻の開発者は、私たちはそれを直接使用する方法を知っているようではないでしょうか?

web.Application

そして、私たちの知識やハイパーリンクPycharm使用:Ctrlキーを押しながらクリックしてアプリケーションを、うわー、新世界は(私も... Kotlinを学ぶために時間を見つけました):

class Application(ReversibleRouter):

    """A collection of request handlers that make up a web application.

    Instances of this class are callable and can be passed directly to

    HTTPServer to serve the application::

        application = web.Application([

            (r"/", MainPageHandler),

        ])

        http_server = httpserver.HTTPServer(application)

        http_server.listen(8080)

        ioloop.IOLoop.current().start()

    The constructor for this class takes in a list of `~.routing.Rule`

    objects or tuples of values corresponding to the arguments of

    `~.routing.Rule` constructor: ``(matcher, target, [target_kwargs], [name])``,

    the values in square brackets being optional. The default matcher is

    `~.routing.PathMatches`, so ``(regexp, target)`` tuples can also be used

    instead of ``(PathMatches(regexp), target)``.

    A common routing target is a `RequestHandler` subclass, but you can also

    use lists of rules as a target, which create a nested routing configuration::

        application = web.Application([

            (HostMatches("example.com"), [

                (r"/", MainPageHandler),

                (r"/feed", FeedHandler),

            ]),

        ])

    In addition to this you can use nested `~.routing.Router` instances,

    `~.httputil.HTTPMessageDelegate` subclasses and callables as routing targets

    (see `~.routing` module docs for more information).

    When we receive requests, we iterate over the list in order and

    instantiate an instance of the first request class whose regexp

    matches the request path. The request class can be specified as

    either a class object or a (fully-qualified) name.

    A dictionary may be passed as the third element (``target_kwargs``)

    of the tuple, which will be used as keyword arguments to the handler's

    constructor and `~RequestHandler.initialize` method. This pattern

    is used for the `StaticFileHandler` in this example (note that a

    `StaticFileHandler` can be installed automatically with the

    static_path setting described below)::

        application = web.Application([

            (r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),

        ])

    We support virtual hosts with the `add_handlers` method, which takes in

    a host regular expression as the first argument::

        application.add_handlers(r"www\.myhost\.com", [

            (r"/article/([0-9]+)", ArticleHandler),

        ])

    If there's no match for the current request's host, then ``default_host``

    parameter value is matched against host regular expressions.

    You can serve static files by sending the ``static_path`` setting

    as a keyword argument. We will serve those files from the

    ``/static/`` URI (this is configurable with the

    ``static_url_prefix`` setting), and we will serve ``/favicon.ico``

    and ``/robots.txt`` from the same directory.  A custom subclass of

    `StaticFileHandler` can be specified with the

    ``static_handler_class`` setting.

    .. versionchanged:: 4.5

       Integration with the new `tornado.routing` module.

    """

うんくそ長い間、私たちは、テンプレート、我々がやりたいテンプレートを見つけるのだろうか?

application = web.Application([
            (r"/", MainPageHandler),
        ])
        http_server = httpserver.HTTPServer(application)
        http_server.listen(8080)
        ioloop.IOLoop.current().start()


どのようにそれを使用するには?
私たちは(MainPageHandler)のクラスを定義する必要があります

class MainPageHandler(web.RequestHandler):
    def get(self, *args, **kwargs):



なぜあなたはそれを書きましたか?私たちは理解して、コメントを見てのRequestHandler

"""Base class for HTTP request handlers.
    Subclasses must define at least one of the methods defined in the
    "Entry points" section below.
"""
SUPPORTED_METHODS = ("GET", "HEAD", "POST", "DELETE", "PATCH", "PUT",
                         "OPTIONS")



しかし、我々は、我々はメソッドを取得する必要があり、そのデータを取得する必要があります。(ウェブの基本)


その後、我々は彼がこんにちは、世界は彼が現れてみましょう、どのようにそれを書くために書くために与える必要がありますか?確かに印刷されない、我々は行う必要があります。

class MainPageHandler(web.RequestHandler):
    def post(self, *args, **kwargs):
    


 

[Input]: 接下来呢?这就完了?
[Input]: 给人写信,怎么可能没有地址,没有邮局呢(前提是距离长的像互联网一般)
[Input]: 所以我们要干啥呢?
[Output]: 找人帮忙:

処理、ルーティング、受信
まず、我々は(MainPageHandler)のクラスを定義します。それは、私たちのアシスタントの一つである側近、コンテンツ取得のための責任があります

class MainPageHandler(web.RequestHandler):
    def get(self, *args, **kwargs):
    


次に私たちは用事を実行するためのアシスタントで、Bに対応するために必要な、アドレスに次のように語りました。

application = web.Application([
            (r"/", MainPageHandler),
        ])


 

[Input]: 那我们还需要什么呢?
[Output]: 前台,没有助手前台,怎么发送信(这个前台包括邮筒)

フロントリトルヘルパーC:

def main():
    http_server = httpserver.HTTPServer(application)
    http_server.listen(8080)
    ioloop.IOLoop.current().start()
[Input]: 看起来是完了,但是我们写在哪里呢,信纸呢 ?
[Output]: 当然是我们的前端页面

暴力:現在のディレクトリに新しいHTMLページを作成するために:私たちは、次のHTMLコードを記述し、index.htmlを彼に呼ばれます。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
</head>
<body>
<h1>Hello,World</h1>
</body>
</html>

そして、手紙を奪うために、私たちに何か少しヘルパーaを送ってください。

class MainPageHandler(web.RequestHandler):
    def get(self, *args, **kwargs):
        self.render("index.html")


次伝える必要がありますアシスタント段階bは、あります

application = web.Application([
            (r"/", MainPageHandler),
        ])


今私達の受信のための、および

def main():
    http_server = httpserver.HTTPServer(application)
    http_server.listen(8080)
    ioloop.IOLoop.current().start()


是非、私たちの手紙を参照してください。

if __name__ == '__main__':
    main()


当社のサーバーが稼働しているapp.py開き、
ブラウザを開き、訪問行く[127.0.0.1:8080](http://127.0.0.1:8080/)

 

上記は、あなたが詳細を知りたい場合は、グループディスカッションや小さなシリーズに歓迎し、サイト全体の単純なプロセスです

おすすめ

転載: blog.csdn.net/weixin_44995023/article/details/91870854