Debug=True in Flask not Working [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am new to Flask and am trying to turn on debug so when I type in "http://127.0.0.1:5000/welcome" into my URL it will provide debugging information.
Instead I am given a 404 URL is not found. Which does make sense as I did not create the welcome.html file yet. What is troubling though is it does not provide debugging information. My question is how can I make debug=True work? Even when I do not have the welcome function declared it does not work.
Currently I have Flask 0.10.1, jinja2 2.8, and Werkzeug 0.11.4.
The terminal prints out:
* Restarting with stat
* Debugger is active!
* Debugger pin code: 281-296-874"
The following is my code:
__author__ = 'Robert'
from flask import Flask, render_template
app = Flask(__name__)
#app.route("/")
def hello():
return "Hello BBck!"
#app.route("/welcome")
def welcome():
return render_template("welcome.html")
if __name__ == "__main__":
app.run(debug=True)

I think that your second "#app.route" statement is missing the URL reference
it should read
#app.route("/welcome")
def welcome():
return render_template("welcome.html")
Then you might still get a 404 error but that should be because you haven't created the welcome.html file in your templates folder

Related

How do i fix this flask sqlalchemy problem? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 13 hours ago.
Improve this question
So basically, im trying to make a website using flask, however, when i type: from flask import SQLAlchemy, it gives me this error message:
File "C:\Users\PycharmProjects\pythonProject4\website_init_.py",
line 2, in
from flask import sqlalchemy ImportError: cannot import name 'SQLAlchemy' from 'flask'
(C:\Users\PycharmProjects\pythonProject4\venv\Lib\site-packages\flask_init_.py)
Anyone know how to solve it?
The correct way to import SQLAlchemy is
from flask_sqlalchemy import SQLAlchemy
source

cannot import name 'reder_template' from 'flask' [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 months ago.
Improve this question
How to fix this error :
cannot import name 'reder_template' from 'flask' (/usr/local/lib/python3.9/site-packages/flask/init.py)
from flask import Flask, request, reder_template, redirect
import os
import sqlite3
currentlocation = os.path.dirname(os.path.abspath(__file__))
myapp = Flask(__name__)
#myapp.route("/")
def homepage():
return render_template("homepage.html")
The problem is a typo, you have imported reder_template instead of render_template from flask.

Declare variables types for python function triggers invalid syntax error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed last year.
Improve this question
I am having trouble why I am getting an invalid syntax error when I declare what my variable is inside my function. The function works when I step through it in python, but not when I try to run the program from the command line.
command line code:
python filename.py
python code:
import pandas as pd
def my_func(df:pd.DataFrame,name:str):
print("Hello world")
def main():
my_func(df=pd.DataFrame(),name='name')
if __name__ == "__main__":
main()
Your code is perfectly valid. Check your Python version - you're probably using a version that doesn't support type hints, such as Python 2.
(Perhaps python resolves to python2?)

Why is it showing the syntax error if I have installed python3 and Kivy? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Im watching this tutorial on YouTube , how to make a POS software using python and kivy . After running this code
import kivy.app import app
from kivy.uix.boxlayout import boxlayout
class SinginWindow(BoxLayout):
pass
class SigninApp(App):
def build(self):
return signinWindow()
if __name__=="__main__":
sa = SigninApp()
sa.run()
I get the following error
import kivy.app import app
^
SyntaxError: invalid syntax
you are typing import twice, it should be from kivy.app import app

Flask - 404 URL was not found [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
When I run my code I get a 404 error.
I tried to add
app.config['SERVER_NAME'] = '127.0.0.1:500-'
but it didn't help.
This is such a basic Flask app, I don't understand what the problem could be.
I have another flask project that works perfect, but for some reason,
the routes aren't working.
Anyone have an idea what could possibly be going wrong?
Here's my code.
from flask import Flask
app = Flask(__name__)
app.route('/')
def index():
return ""
if __name__ == '__main__':
app.run(debug=True)
You forgot to use # for the decorator. Below should work
from flask import Flask
app = Flask(__name__)
#app.route('/')
def index():
return ""
if __name__ == '__main__':
app.run(debug=True)

Categories

Resources