Skip to content

Instantly share code, notes, and snippets.

@Franck1333
Created April 24, 2020 15:14
Show Gist options
  • Save Franck1333/c79c8f0a340b46960884086c74bd26e8 to your computer and use it in GitHub Desktop.
Save Franck1333/c79c8f0a340b46960884086c74bd26e8 to your computer and use it in GitHub Desktop.
Make a webserver with Python and Flask together!
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#https://projects.raspberrypi.org/en/projects/python-web-server-with-flask/
from flask import Flask, render_template
app = Flask(__name__)
#Static
@app.route('/')
def index():
return render_template('index.html')
@app.route('/cakes')
def cakes():
return render_template('cakes.html')
#Dynamic
@app.route('/coucou/<name>')
def hello(name):
return render_template('page.html', name=name)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment