Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions test_flask.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,56 @@
'''

test_flask.py

@summary: Comparing (RAM usage) of different webframeworks
@since: 4 Mar 2016
@author: Andreas
@home github.com/drandreaskrueger/pythonMicroframeworks
@license: MIT but please donate:
@bitcoin: 14EyWS5z8Y5kgwq52D3qeZVor1rUsdNYJy

@thanks: to Kevin Veroneau. I based parts of this on his code snippets.
@thanks: to Kevin Veroneau. I based parts of this on his code snippets.
http://www.pythondiary.com/blog/Feb.14,2012/too-many-micro-webframeworks.html

'''

from flask import Flask, __version__ # pip install Flask

HOST, PORT= '127.0.0.1', 5000
from flask import Flask, __version__ # pip install Flask

HOST, PORT = '127.0.0.1', 5000

app = Flask(__name__)


@app.route('/hello/<name>')
def hello(name="Earth"):
return "Hello %s!" % name
return f"Hello {name}!"


def run_flask_simplest():
app.run()



def run_server(host=HOST, port=PORT):
print "Flask",
from time import sleep; sleep(0.1) # only because of stdout / stderr printing
print("Flask"),
from time import sleep
sleep(0.1) # only because of stdout / stderr printing
app.run(host=host, port=port)



def url(host=HOST, port=PORT):
return "http://%s:%s/hello/World" % (host, port)
return f"http://{host}:{port}/hello/World"


def version():
return ("flask", __version__)



if __name__ == '__main__':
# run_flask_simplest()

from sys import argv as a; port=int(a[1]) if len(a)>1 else PORT # get port from commandline argument


from sys import argv as a
# get port from commandline argument
port = int(a[1]) if len(a) > 1 else PORT

run_server(port=port)