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 :: default style matplotlib python 
Python :: pyqt5 message box 
Python :: Right click context menu of a file in Python 
Python :: rotate x labels in plots, matplotlib 
Python :: how to fill an array with consecutive numbers 
Python :: upgrade to latest django version 
Python :: gdscript 2d movement 
Python :: sort by column dataframe pyspark 
Python :: python locks 
Python :: ctx.save_for_backward 
Python :: who is elcharitas 
Python :: how to pronounce aesthetic 
Python :: user input dictionary python 
Python :: python stack class 
Python :: how to strip a list in python 
Python :: python one line return 
Python :: write txt python 
Python :: how to get 2 random inputs in a list using for loop 
Python :: python datetime from isoformat 
Python :: plt.savefig without showing 
Python :: check cuda available tensorflow 
Python :: os run shell command python 
Python :: make text bold python 
Python :: how to insert a placeholder text in django modelform 
Python :: how to wait in pygame 
Python :: web scraping linkedin profiles python jupyter 
Python :: word pattern in python 
Python :: most frequent element in a list 
Python :: adaptive thresholding cv2 python 
Python :: django run queryset in terminal 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =