Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python flask sample application

from flask import *
app = Flask(__name__)

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

if __name__ == "__main__":
  app.run(host="0.0.0.0", port=8080, debug=False)
Comment

flask app example

# Extremely simple flask application, will display 'Hello World!' on the screen when you run it
# Access it by running it, then going to whatever port its running on (It'll say which port it's running on).
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

if __name__ == '__main__':
    app.run()
Comment

python basic flask app

# Imports necessary libraries
from flask import Flask 
# Define the app
app = Flask(__name__)

# Get a welcoming message once you start the server.
@app.route('/')
def home():
    return 'Home sweet home!'

# If the file is run directly,start the app.
if __name__ == '__main__':
    app.run(Debug=True)

# To execute, run the file. Then go to 127.0.0.1:5000 in your browser and look at a welcoming message.
Comment

flask app example

import flask

# A simple Flask App which takes
# a user's name as input and responds
# with "Hello {name}!"

app = flask.Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def index():
    message = ''
    if flask.request.method == 'POST':
        message = 'Hello ' + flask.request.form['name-input'] + '!'
    return flask.render_template('index.html', message=message)

if __name__ == '__main__':
    app.run()
Comment

basic flask app python

#Import Flask, if not then install and import.

import os
try:
  from flask import *
except:
  os.system("pip3 install flask")
  from flask import *

app = Flask(__name__)

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

if __name__ == "__main__":
  app.run(host="0.0.0.0", port=8080, debug=False)
Comment

Create a Flask App

# save this as app.py
from flask import Flask, escape, request

app = Flask(__name__)

@app.route('/')
def hello():
    name = request.args.get("name", "World")
    return f'Hello, {escape(name)}!'
  
  # twitter : @MasudSha_
  # @MasudShah
Comment

PREVIOUS NEXT
Code Example
Python :: ask a question on python 
Python :: find todays date in python 
Python :: insert column at specific position in pandas dataframe 
Python :: max of first element in a list of tuples 
Python :: y=mx+b python 
Python :: how to convert async function to sync function in python 
Python :: program to segregate positive and negative numbers in same list 
Python :: how to traverse a linked list in python 
Python :: Finding the sum of even Fibonacci numbers less than or equal to given limit 
Python :: convert streamlit imageBytes = file.read() to image 
Python :: get most repeated instance in a queryset django 
Python :: python is not writing whole line 
Python :: how to lock writing to a variable thread python 
Python :: drop a column in pandas 
Python :: string list into list pandas 
Python :: Python program that takes 2 words as input from the user and prints out a list containing the letters that the 2 words have in common 
Python :: json load from file python 3 
Python :: masking function pyspark 
Python :: payizone 
Python :: how to make basic inventory setup in python 
Python :: pyqt5 message box 
Python :: matplotlib axes limits 
Python :: python -m http 
Python :: How to create an efficient median finder for a stream of values, in Python? 
Python :: python sort list of lists by second element 
Python :: python yyyymmdd 
Python :: print decimal formatting in python 
Python :: subprocess the system cannot find the file specified 
Python :: django check if user is staff in template 
Python :: df change column names 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =