Skip to content

Instantly share code, notes, and snippets.

@synthetic-intelligence
Forked from drgarcia1986/bottle_hello.py
Created January 27, 2021 09:37
Show Gist options
  • Save synthetic-intelligence/d9b3fe5419fc149dbc5c84d9258589e2 to your computer and use it in GitHub Desktop.
Save synthetic-intelligence/d9b3fe5419fc149dbc5c84d9258589e2 to your computer and use it in GitHub Desktop.

Revisions

  1. @drgarcia1986 drgarcia1986 revised this gist Jul 5, 2015. 6 changed files with 16 additions and 15 deletions.
    4 changes: 1 addition & 3 deletions bottle_hello.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    #!/usr/bin/env python
    # encoding: utf-8

    # -*- coding: utf-8 -*-
    from bottle import route, run


    5 changes: 2 additions & 3 deletions django_hello.py
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    #!/usr/bin/env python
    # encoding: utf-8
    # -*- coding: utf-8 -*-

    # Settings
    from django.conf import settings
    @@ -25,7 +24,7 @@
    def index(request):
    return HttpResponse('<h1>Hello Word</h1>')


    # Routes
    urlpatterns = (
    url(r'^$', index),
    )
    4 changes: 1 addition & 3 deletions falcon_hello.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    #!/usr/bin/env python
    # encoding: utf-8

    # -*- coding: utf-8 -*-
    import falcon


    4 changes: 1 addition & 3 deletions flask_hello.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    #!/usr/bin/env python
    # encoding: utf-8

    # -*- coding: utf-8 -*-
    from flask import Flask


    10 changes: 10 additions & 0 deletions muffin_hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # -*- coding: utf-8 -*-
    import muffin


    app = muffin.Application('hello')


    @app.register('/')
    def products(request):
    return {'hello': 'world'}
    4 changes: 1 addition & 3 deletions tornado_hello.py
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    #!/usr/bin/env python
    # encoding: utf-8

    # -*- coding: utf-8 -*-
    import tornado.web
    import tornado.httpserver
    import tornado.ioloop
  2. @drgarcia1986 drgarcia1986 revised this gist Jan 19, 2015. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions falcon_hello.py
    Original file line number Diff line number Diff line change
    @@ -13,3 +13,9 @@ def on_get(self, req, resp):
    app = falcon.API()

    app.add_route(r'/', Index())


    if __name__ == '__main__':
    from wsgiref import simple_server
    httpd = simple_server.make_server('127.0.0.1', 8000, app)
    httpd.serve_forever()
  3. @drgarcia1986 drgarcia1986 created this gist Jan 18, 2015.
    12 changes: 12 additions & 0 deletions bottle_hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/usr/bin/env python
    # encoding: utf-8

    from bottle import route, run


    @route('/')
    def index():
    return '<h1>Hello World/h1>'


    run(host='localhost', port=8000)
    39 changes: 39 additions & 0 deletions django_hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #!/usr/bin/env python
    # encoding: utf-8

    # Settings
    from django.conf import settings


    settings.configure(
    DEBUG=True,
    SECRET_KEY='secretfoobar',
    ROOT_URLCONF=__name__,
    MIDDLEWARE_CLASSES=(
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    )
    )


    # Views
    from django.http import HttpResponse
    from django.conf.urls import url


    def index(request):
    return HttpResponse('<h1>Hello Word</h1>')


    urlpatterns = (
    url(r'^$', index),
    )


    # RunServer
    if __name__ == '__main__':
    from django.core.management import execute_from_command_line
    import sys

    execute_from_command_line(sys.argv)
    15 changes: 15 additions & 0 deletions falcon_hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/bin/env python
    # encoding: utf-8

    import falcon


    class Index():
    def on_get(self, req, resp):
    resp.status = falcon.HTTP_200
    resp.body = '{"msg": "Hello World"}'


    app = falcon.API()

    app.add_route(r'/', Index())
    15 changes: 15 additions & 0 deletions flask_hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/bin/env python
    # encoding: utf-8

    from flask import Flask


    app = Flask(__name__)


    @app.route('/')
    def index():
    return '<h1>Hello World</h1>'


    app.run()
    22 changes: 22 additions & 0 deletions tornado_hello.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/usr/bin/env python
    # encoding: utf-8

    import tornado.web
    import tornado.httpserver
    import tornado.ioloop


    class IndexHandler(tornado.web.RequestHandler):
    def get(self):
    self.finish('<h1>Hello World</h1>')


    if __name__ == '__main__':
    app = tornado.web.Application([(r'/', IndexHandler)])
    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(8000)
    try:
    print('Server Start')
    tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
    print('Server Stop')