Computer Science CS50 Lecture Notes - Lecture 1: Web Framework, Comma-Separated Values, Full City

77 views19 pages

Document Summary

But web applications can be written with any number of other frameworks, or even built-in python functions: an application using flask can be as simple as, from flask import flask, render_template app = flask(__name__) @app. route("/") def index(): return render_template("index. html": this program just returns the template index. html when the user visits /, or the default webpage, of the server. Frosh ims: let"s look at froshims0, which has a templates directory with various files ending in . html, as well as application. py, from flask import flask, render_template, request app = flask(__name__) @app. route("/register", methods=["post"]) def register(): if request. form["name"] == "" or request. form["dorm"] == return render_template("failure. html") return render_template("success. html": we added a register function that will respond differently based on the user"s input. {% endblock %: and success. html is similar, {% extends "layout. html" %} {% endblock %: index. html, meanwhile, had the actual form, {% extends "layout. html" %}

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions