Giter Site home page Giter Site logo

discover-flask's Introduction

Discover Flask

Full Stack Web Development with Flask.

http://discoverflask.com

Build Status

Flask is a micro web framework powered by Python. Its API is fairly small, making it easy to learn and simple to use. But don't let this fool you, as it's powerful enough to support enterprise-level applications handling large amounts of traffic. You can start small with an app contained entirely in one file, then slowly scale up to multiple files and folders in a well-structured manner as your site becomes more and more complex.

real_python_logo

Please note: This is a tutorial series, which is still in progress. The source code is not meant to be used until the end of the series.

Support

Please help us keep this free, open source project going. Purchase the Real Python course. Provide gratitude through Gratipay. Star this repo. Tweet about it. Anything helps. Thank you!

Support via Gratipay

Contents

Part Title Git Tag
1 Setting Up a Static Site (blog post) part1
2 Creating a login page (blog post) part2
3 User Authentication part3
4 Template Inheritance part4
5 Databases part5
6 List Comprehensions N/A
7 Unit Tests part7
8 Deploying to Heroku part8
9 SQLAlchemy part9
10 Configuration part10
11 Secret Key part11
12 Heroku Configuration Settings part12
13 Heroku Postgres Setup part13
14 Local PostgreSQL Setup part14
15 Managing Database Migrations part15
16 Database Downgrades with Flask-Migrate/Alembic part16
17 Virtualenvwrapper part17
18 Password Hashing part18
19 Blueprints part19
20 Blueprints Redux part20
21 User Authentication (part 2) part21
22 Unit Testing with Flask-Testing part22
23 Session Management with Flask-Login part23
24 Testing User Login and Logout part24
25 User Registration (functionality and unit tests) part25
26 Finalize Messaging System part26
27 Test Coverage with coverage.py part27
28 Flask Testing! part28
29 Flask Testing (increase test coverage) part29
30 Continuous Integration part30

You can view the entire video playlist here.

Links

  • Nice Vagrant Instance for Discover Flask, for use with PyJenkinsCI - a test Jenkins Continuous Integration (CI) for Python projects, compatible with Mac OSX and Ubuntu systems. (Thanks, Apollo!)
  • Awesome project, based on the series -> HomeCenter

discover-flask's People

Contributors

greyli avatar mjhea0 avatar mroswell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discover-flask's Issues

Keyerror

Traceback (most recent call last):
File "manage.py", line 9, in
from solarpi.app import create_app
File "/home/amani/Desktop/new/solarpi/solarpi/app.py", line 10, in
from solarpi.settings import ProdConfig
File "/home/amani/Desktop/new/solarpi/solarpi/settings.py", line 7, in
class Config(object):
File "/home/amani/Desktop/new/solarpi/solarpi/settings.py", line 8, in Config
SECRET_KEY = os_env['SOLARPI_SECRET']
File "/home/amani/Desktop/new/.venv/lib/python2.7/UserDict.py", line 40, in getitem
raise KeyError(key)
KeyError: 'SOLARPI_SECRET'

i generated the key but still am getting the same error, can anyone help?

Confusion

In app.py

--connect to database
def connect_db():
return sqlite3.connect('posts.db')

Do we need to include this? Aren't we already exporting it to DATABASE_URL='sql:///posts.db' and we are using SQLAlchemy for this project.I think we should comment this line.

How to make a database for each html page in my web application? flask, python, html,sql

I'm currently building a flask web application using Microsoft Azure. The basic idea is just a blog for my school which I'm doing as a project. For this web application, I have two html pages. A home page where people just chat and a calendar page. yes not the best ideas but it's sufficient. What i'm wondering is how i select a database for each html page. Since it's like a forum blog type page, I already have the form and the script for that ready but when I enter something, it shows up for all the pages. I've made two databases, database.db for the home page and calendar.db for the calendar page. So far, everything i've been submitting into the forms is going into database.db and not calendar.db for the calendar.html page. So, i've made the database for the calendar page and made a table for it but can't seem to connect it to calendar.db.

Here is my code:

app.py


from flask_cors import CORS

from models import create_post, get_posts





app = Flask(__name__)



CORS(app)



u/app.route('/', methods=['GET','POST'])

def index():



if request.method == 'GET':

pass

if request.method == 'POST':

name = request.form.get('name')

post = request.form.get('post')

create_post(name, post)



posts = get_posts()



return render_template('index.html', posts=posts)



u/app.route('/calendar.html', methods=['GET','POST'])

def calendar():



if request.method == 'GET':

pass

if request.method == 'POST':

name = request.form.get('name')

post = request.form.get('post')

create_post(name, post)



posts = get_posts()



return render_template('calendar.html', posts=posts)



if __name__ == '__main__':

app.run(host="0.0.0.0", port=80)





and then models.py


import sqlite3 as sql

from os import path



ROOT = path.dirname(path.relpath((__file__)))



def create_post(name,content):

con = sql.connect(path.join(ROOT, 'database.db'))

cur = con.cursor()

cur.execute('insert into posts (name, content) values(?, ?)', (name, content))

con.commit()

con.close()



def get_posts():

con = sql.connect(path.join(ROOT, 'database.db'))

cur = con.cursor()

cur.execute('select * from posts')

posts = cur.fetchall()

return posts



and finally my html page for the calendar :


<!doctype html>

<center>



<head style="color:green; font-family: 'Times New Roman', Times, serif;font-size: 400px;">

<link rel="stylesheet" href="styles.css">



<font size = "+100">Important Events Coming Up</font>

<title>EcoNet</title>

</head>

<br>

<br>

<br>



<br>

<table>

<tr>

<th>

<a href="/">Parent Blog</a>

</th>

<th>

<a href="meeting.html">Teachers to Parents</a>

</th>

</tr>



</table>



<table >

<thead>



<tr>



<td >Mon</td>

<td>Tue</td>

<td>Wed</td>

<td>Thu</td>

<td>Fri</td>

<td>Sat</td>

<td>Sun</td>



</tr>



</thead>



<tbody>



<tr>

<td >29</td>

<td >30</td>

<td >31</td>

<td>1</td>

<td>2</td>

<td>3</td>

<td>4</td>

</tr>



<tr>

<td>5</td>

<td>6</td>

<td>7</td>

<td>8</td>

<td>9</td>

<td>10</td>

<td>11</td>

</tr>



<tr>

<td>12</td>

<td>13</td>

<td>14</td>

<td>15</td>

<td>16</td>

<td>17</td>

<td ></td>

</tr>



<tr>

<td>19</td>

<td>20</td>

<td>21</td>

<td>22</td>

<td>23</td>

<td>24</td>

<td>25</td>

</tr>



<tr>

<td>26</td>

<td>27</td>

<td>28</td>

<td>29</td>

<td>30</td>

<td>31</td>

<td >1</td>

</tr>



</tbody>





<h1 style="color:teal; font-family: 'Times New Roman', Times, serif;"> Type Down Below To Remind Anyone of Where and When the Gathering Will Happen</h1>





<body style = "background-color:lightgreen;">

<form action='/calendar.html' method='post'>

<input placeholder='Name' name='name'>

<input placeholder='Post Content' name='post'>

<input type='submit' value='Submit'>

</form>

{% for post in posts %}

<div>

{{ post[1] + ': ' + post[2] }}

</div>

{% endfor %}

</body>

</center>

</html>

my html is not the best.

It would be great if you guys could help me. I've made another models.py with different variables and connected them to calendar.html/calendar.db but that hasn't work. I've done a lot of things and followed the same steps i got database.db to work but I can't figure it out.

Thank you

Sample material does not match the videos

Hi,

I started following Part-1 and only found that the downladable examples are different than those used in the course.
and the material is about 7 years old.

Are there any plans to modernate the material to the latest Visual Code and Python 3.9 ?

Best,
Mickey

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.