#๐ Python file is not running
21 messages ยท Page 1 of 1 (latest)
@silk jewel
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
code:
from weather import get_current_weather
from waitress import serve
app = Flask(__name__)
@app.route("/")
@app.route('/index')
def index():
return render_template('index.html')
@app.route('/weather')
def get_weather():
city = request.args.get('city')
weather_data = get_current_weather('city')
return render_template(
"weather.html",
title = weather_data["name"],
status = weather_data["weather"][0]["description"].capitalize(),
temp=f'{weather_data["main"]["temp"]:.1f}',
feels_like=f'{weather_data["main"]["feels_like"]:.1f}'
)
if __name__ == "__main__":
serve(app)```
Hey @silk jewel!
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
PS C:\Users\GrafiX\Documents\vs code\flask> & "c:/Users/GrafiX/Documents/vs code/flask/venv/Scripts/python.exe" "c:/Users/GrafiX/Documents/vs code/flask/main.py"
its shows this
and didnt run
i run the file by clicking the run python file option on vs code
Try flask run --app main
the main problem is that when i remove serve(app)
and replace it with app.run() it started to work
Maybe stick to app.run() then?
but bro i want to use this module
Then use waitress-serve --host 127.0.0.1 main:app
its for production development
damn bro this worked thx a lotโค๏ธ
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.