Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make a flask server in python

# This is the code
# Find me on discord ZDev1#4511
# We shouldn't install flask in the terminal, it is already imported
from flask import Flask

app = Flask(__name__)

# route
@app.route('/')
# route function
def home():
  # send 'hey!'
  return 'hey!'

# listen
if __name__ == "__main__":
  app.run(port=3000)
  # if you need to make it live debuging add 'debug=True'
  # app.run(port=3000, debug=True)
  
 # Hope you enjoyed ;)
Comment

how to make a flask server in python

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

flask start development server

$ export FLASK_APP=hello
$ export FLASK_ENV=development
$ flask run
Comment

PREVIOUS NEXT
Code Example
Python :: lambda function in python 
Python :: apply on dataframe access multiple columns 
Python :: read part of file pandas 
Python :: tf MaxPooling2D 
Python :: ForeignKey on delete django 
Python :: pandas filter rows by value 
Python :: find a key in a dictionary python 
Python :: How to Use Python Glob Module 
Python :: django fieldset 
Python :: python range in intervals of 10 
Python :: check for prime in python 
Python :: Python Making a New Directory 
Python :: numpy array serialize to string 
Python :: double quotes in python dictionary 
Python :: pandas check if any of the values in one column exist in another 
Python :: python get first letter of string 
Python :: python single line if 
Python :: animations on canvas tkinter 
Python :: pandas invert a boolean Series 
Python :: delete last message discord.py 
Python :: python key from values 
Python :: append a list to a list python 
Python :: python list join array string space 
Python :: python regex search a words among list 
Python :: python how to align text writen to a file 
Python :: get current url with parameters url django 
Python :: Got AttributeError when attempting to get a value for field `name` on serializer 
Python :: install python windows powershell 
Python :: python 2d dictionary 
Python :: how to install django 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =