Skip to content
Snippets Groups Projects
Commit c3493841 authored by Hongyi Li's avatar Hongyi Li
Browse files

Initial commit

parent b0c54920
Branches
No related tags found
No related merge requests found
Showing
with 18 additions and 49 deletions
# Flask - Lab 1
fuction test
File deleted
No preview for this file type
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SECRET_KEY'] = '<please generate a new secret key>'
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://USERNAME:PASSWORD@csmysql.cs.cf.ac.uk:3306/YOUR_DATABASE'
app.config['SECRET_KEY'] = '<57d154ddc3b838a7db3d029265dd9fe5ec654105f3804af9>'
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://c2074413:Lhy!252318@csmysql.cs.cf.ac.uk:3306/c2074413_CMT120_practice'
db = SQLAlchemy(app)
from blog import routes
File added
File added
File added
File moved
from flask import render_template, url_for
from blog import app
from blog.models import User, Post
@app.route("/")
@app.route("/home")
def home():
posts=Post.query.all()
return render_template('home.html',posts=posts)
posts=Post.query.all()
return render_template('home.html',posts=posts)
@app.route("/about")
def about():
return render_template('about.html', title='About')
return render_template('about.html', title='About')
\ No newline at end of file
File moved
File moved
{% extends "layout.html" %}
{% block content %}
{% for post in posts %}
<p>"{{ post.title }}"&nbsp
by {{ post.user.username }}</p>
<p>"{{ post.title }}" &nbsp
by {{ post.user.username }}</p>
<p>{{ post.content }}</p>
{% endfor %}
{% endblock content %}
File moved
# Flask - Lab 1
This is a snapshot of the state of blog app from Task 19 to the end of the exercise.
Functionality: basic initial blogging website structure
Previous task: flask-lab-1.1 (Hello, World!)
from blog import app as application
if __name__ == '__main__':
app.run(debug=True)
from flask import Flask, render_template, url_for
app = Flask(__name__)
@app.route("/")
@app.route("/home")
def home():
return render_template('home.html', title='Home')
@app.route("/about")
def about():
return render_template('about.html', title='About Us')
click==7.1.2
dnspython==2.1.0
email-validator==1.1.2
Flask==1.1.2
Flask-Login==0.5.0
Flask-MySQL==1.5.2
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
idna==3.1
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
PyMySQL==1.0.2
SQLAlchemy==1.3.22
Werkzeug==1.0.1
WTForms==2.3.3
File moved
{% extends "layout.html" %}
{% block content %}
<h1>This is About Us page!!!!</h1>
{% endblock content %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment