Created
April 24, 2020 15:14
-
-
Save Franck1333/c79c8f0a340b46960884086c74bd26e8 to your computer and use it in GitHub Desktop.
Make a webserver with Python and Flask together!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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