Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialArnaldo Acosta
15,870 PointsI've been using Sublime Text 3 for Python courses. Now I'm starting the Flask course and I don't know how to set it up
I've already installed Python 3.6 along with pip, and I've been using Sublime Text 3 although Python Basics and Python Collection courses but now I'm on the Flask course and I don't even know if I can make use of it on Sublime too or that's even possible. Any help would be much appreciated!
2 Answers
nickyp
2,140 PointsFirst, you will install everything you need for Flask through terminal (Pip). Then, you will create a .py file, that's where most of the Flask setup code would be. You can use sublime to do that.
Below is a simple Flask app that will render Hello World! on the index route
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == "__main__":
app.run()
I would also suggest reading Flask documentation
Arnaldo Acosta
15,870 Pointsnickyp, see THAT and having the file moved to the scripts folder actually did the trick! Thanks very much again for your time!
nickyp
2,140 PointsNo problem!
Arnaldo Acosta
15,870 PointsArnaldo Acosta
15,870 PointsThanks nickyp, you see I created a virtual environment, installed Flask successfully using pip install Flask, got Python running on Sublime with the newly created virtualenv and still getting ImportError: cannot import name 'Flask' whenever I try to run the Flask app you mentioned above. Thanks for taking the time to answer btw
nickyp
2,140 Pointsnickyp
2,140 PointsArnaldo Acosta, did you name your python file "flask.py"? That might be why you are getting this error