Jul-27-2019, 05:04 AM
Jul-27-2019, 11:24 AM
Correct. Wondering why is standard 'str' not set.
Jul-27-2019, 10:54 PM
By the way, the author of the course mentioned that he added this json with posts
https://github.com/CoreyMSchafer/code_sn...posts.json
Could anyone tell me how to actually add it? Never had any business with json.
https://github.com/CoreyMSchafer/code_sn...posts.json
Could anyone tell me how to actually add it? Never had any business with json.
Jul-28-2019, 12:31 AM
I think this is what you're looking for - https://realpython.com/python-json/
Jul-28-2019, 11:46 PM
(Jul-28-2019, 12:31 AM)SheeppOSU Wrote: [ -> ]I think this is what you're looking for - https://realpython.com/python-json/
I created a list json_data ( had to use raw github link )
import requests import json raw_json = requests.get("https://raw.githubusercontent.com/CoreyMSchafer/code_snippets/master/Python/Flask_Blog/snippets/posts.json") json_data = json.loads(raw_json.content)now just to figure out where to put this.
Aug-12-2019, 11:48 PM
Can anybody please help me with this error
now ran
Error:C:\Python37\kodovi\Projects\Flask_Blog>run.py
Traceback (most recent call last):
File "C:\Python37\kodovi\Projects\Flask_Blog\run.py", line 1, in <module>
from flaskblog import app
File "C:\Python37\kodovi\Projects\Flask_Blog\flaskblog\__init__.py", line 2, in <module>
from flask import Flask
File "C:\Python37\Anaconda3\lib\site-packages\flask\__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "C:\Python37\Anaconda3\lib\site-packages\flask\app.py", line 25, in <module>
from . import cli, json
File "C:\Python37\Anaconda3\lib\site-packages\flask\cli.py", line 18, in <module>
import ssl
File "C:\Python37\Anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
The mess started when I decided to change the name of my root folder from 'Environments' to more suitable 'Projects'. So now I have Projects/Flask_blog and within Flask_blog have run.py and flaskblog subfolder with all the code for the web site.now ran
run.py
again and got this:Error:C:\Python37\lib\site-packages\flask_sqlalchemy\__init__.py:835: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
* Serving Flask app "flaskblog" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Restarting with stat
C:\Python37\lib\site-packages\flask_sqlalchemy\__init__.py:835: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
* Debugger is active!
* Debugger PIN: 146-718-091
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [13/Aug/2019 02:04:04] "GET / HTTP/1.1" 404 -
127.0.0.1 - - [13/Aug/2019 02:04:04] "GET /favicon.ico HTTP/1.1" 404 -
Aug-13-2019, 03:14 PM
You have not set to SQLALCHEMY_TRACK_MODIFICATIONS to False as you metion before in post.
Add line 2.
Add line 2.
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://site.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
Quote:The mess started when I decided to change the name of my root folder from 'Environments' to more suitable 'Projects'. So now I have Projects/Flask_blog and within Flask_blog have run.py and flaskblog subfolder with all the code for the web site.Just clone from GitHub as Corery has all step in blog tutorial there.
Aug-13-2019, 11:14 PM
I added
Thank you.
After cloning to my project folder starting run.py and trying to open a web site leads to this error
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
but it didn't give me desired outcome. Still the same problem. I guess I'll have to clone the whole code_snippets repository.Thank you.
After cloning to my project folder starting run.py and trying to open a web site leads to this error
Error:AttributeError: 'NoneType' object has no attribute 'drivername'
Aug-14-2019, 02:35 PM
(Aug-13-2019, 11:14 PM)Truman Wrote: [ -> ]I guess I'll have to clone the whole code_snippets repository.I told in in post #2 about DownGit or cooler GitZip where can download individual files and folder.
Quote:After cloning to my project folder starting run.py and trying to open a web site leads to this errorYou most link to what where you are,should not be necessary to mention this
Link if i test eg
08-Posts
.Here a run,i delete database
site.db
so i can make new one.G:\all_flask\08-Posts λ ls flaskblog/ run.py # Make database site.db G:\all_flask\08-Posts λ ptpython >>> from flaskblog import db >>> db.create_all() >>> exit()Add line 2:
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://site.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = FalseTest run:
G:\all_flask\08-Posts λ python run.py * Serving Flask app "flaskblog" (lazy loading) * Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead. * Debug mode: on * Restarting with stat * Debugger is active! * Debugger PIN: 334-187-997 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) 127.0.0.1 - - [14/Aug/2019 16:19:21] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [14/Aug/2019 16:19:21] "GET /static/main.css HTTP/1.1" 200 - 127.0.0.1 - - [14/Aug/2019 16:19:21] "GET /favicon.ico HTTP/1.1" 404 - 127.0.0.1 - - [14/Aug/2019 16:20:09] "GET /about HTTP/1.1" 200 - 127.0.0.1 - - [14/Aug/2019 16:20:10] "GET /home HTTP/1.1" 200 - 127.0.0.1 - - [14/Aug/2019 16:20:13] "GET /register HTTP/1.1" 200 - 127.0.0.1 - - [14/Aug/2019 16:20:28] "POST /register HTTP/1.1" 302 - 127.0.0.1 - - [14/Aug/2019 16:20:28] "GET /login HTTP/1.1" 200 - 127.0.0.1 - - [14/Aug/2019 16:20:32] "GET /login HTTP/1.1" 200 -No error site work and i can register a new user,and
New Post
message get added to database.