realpython / discover-flask Goto Github PK
View Code? Open in Web Editor NEWFull Stack Web Development with Flask.
Home Page: http://discoverflask.com
Full Stack Web Development with Flask.
Home Page: http://discoverflask.com
Details: pallets/flask#1135
hello, I visit url and find there is only login function. So is there no register and email authentication function?
The video links in the readme.md are dead
For example, self.assertTrue(current_user.is_active()) is used throughout tests. However, self.assertTrue(current_user.is_active) is the correct statement.
Link for reference: https://stackoverflow.com/questions/32750526/flask-login-raises-typeerror-bool-object-is-not-callable-when-trying-to-overr
Thanks
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
Thanks :)
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?
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.