#๐ Flask
175 messages ยท Page 1 of 1 (latest)
@weary sparrow
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.
Should I open them, or?
Is there something else I should do to activate the flask
@spice sleet Need a help, sorry to bother
Create a Basic Flask Application
Everything inside __pycache__ subdirectories has been made by Python as it loads modules. Ignore them - they're cached compiled bytecode of the associated module so that Python doesn't need to compile it a second time unless the source file changes.
Heres the code
from flask import Flask
app = Flask(name)
@app.route('/')
def home():
return 'Hello, World!'
if name == 'main':
app.run(debug=True)
Hey @vital trout!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
And run it
Open a web browser and go to http://127.0.0.1:5000/. You should see the message "Hello, World!" displayed on the page. This confirms that your Flask application is working.
In a new python, right?
Alright let me try
Like open it in cmd?
I'm wrong sorry
Dw
Create a Flask Application
Like this one
from flask import Flask
app = Flask(name)
@app.route('/')
def home():
return "Hello, World!"
if name == 'main':
app.run(debug=True)
Hey @vital trout!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
basic code
I have to run the code again?
Then run it to see if theres no problem
And then
Organize your project
For exemple
It just ran the code and lagged
Like ran the code and closed python
And in the init.py you need to instert your flask file
Heres an example
from flask import Flask
def create_app():
app = Flask(name)
with app.app_context():
# Import parts of our application
from . import routes
# Register Blueprints, etc.
return app
Go on http://127.0.0.1:5000/
And tell me what you see
The python one, right?
Still the same
I can't read, because it's closing fast
But I did see the word "Error"
Wait there's two files
"Flask File"
"Flask"
Delete Flask File
Done
Open "Flask"
It opened and closed, but didn't seem that it ran the code
Alright
That's weird
It ran the code and closed
I saw "Traceback"
When it opened
That's what I did tho?
So when you open it it instanly close ?
So
When you go to the py app
You type python app.py
And that open and then close ?
Try this script
`from flask import Flask
app = Flask(name)
@app.route('/')
def index():
return 'Hello, Flask!'
if name == 'main':
app.run()
`
Still the same
Do you think it's a lag??
I don't know, maybe it's a glitch or something
@vital trout It's working
Like
I deleted the file and re-coded
And in the init.py you need to instert your flask file
Heres an example
from flask import Flask
def createapp():
app = Flask(_name)
with app.app_context():
# Import parts of our application
from . import routes
Register Blueprints, etc.
return app
So
Its like that you put your Flask File in your Python Project
Ill send you pictures you will understand
Alright thank you
Ohh, lemme go try real quick
Like I should create a new folder?
Ohhh
Yeah
Aight created a new folder
Wait, what about config.py and the above?
Like..I'm suppose to code them?
Yeah but i can send you the codes
Yeah please
Try this config first
If this is ChatGPT, please don't provide help using ChatGPT...
I learned with ChatGPT
Firstly, you'll have to open up your project file inside of an editor
Huh
Oh alrighty
And have you installed flask, pip install flask
yeah
everything is done
I did all that, I just have to organise the project
he need to know how to add flask in a python project
Have you got your website working?
Yep
Oh
Everything is working as i said
I just took a ChatGPT config to show him how to add flask into a python project
!rule chatgpt
Uh
I'm kinda new to python so I don't know how to code those that much
@rich sundial I think I organized my project now, uhm how am I supposed to run it now?
run.py maybe?
Uh
The organization thing was not nessacary
Hi could you help me to install Flask.
#โ๏ฝhow-to-get-help
One sec
I think I coded the run.py wrong
Not sure though
@vital trout What was the coding for run.py?
dm me
@weary sparrow in case this person sends any files in DMs, you shouldn't download them, it might be a virus.
Did you run it?
No, they didn't send anything yet
Oh
Uh the "from import" thingy
Should I change something?
from app import create_app
Like here
@rich sundial
@buoyant anvil
Exactly
Ohh
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.