![]() ![]() ![]() But we do ask you to log in every now and then and click the “Run until 3 months from today” button, just so that we know you’re still interested in keeping it running.īefore we do any coding, let’s check out the site that PythonAnywhere has generated for us by default. Don’t worry! You can keep a free site up and running on PythonAnywhere for as long as you want, without having to pay us a penny. But if you have a free account, you’ll see something saying that your site will be disabled on a date in three months’ time. If you have a paid account, you won’t see that – it only applies to free accounts. We’ll ignore most of these for the moment, but one that is worth noting is the “Best before date” section. But the one that’s currently selected is the one you just created, and if you scroll down a bit you can see all of its settings. ![]() If you had multiple websites in your PythonAnywhere account, they would appear there too. You can see that the host name for the site is on the left-hand side, along with the “Add a new web app” button. There will be a brief pause while PythonAnywhere sets up the website, and then you’ll be taken to the configuration page for the site: Once you’re sure you’re OK with the filename, click “Next”. (It will overwrite any other file with the same name, so if you’re not using a new PythonAnywhere account, make sure that the file that it’s got in the “Path” input box isn’t one of your existing files.) The default should be fine it will create a subdirectory of your home directory called mysite and then will put the Flask code into a file called flask_app.py inside that directory. PythonAnywhere is asking you where it should create a directory and put a single file with a really really simple website. Now, Flask is a particularly lighweight framework, and you can write a simple Flask app in a single file. Code on PythonAnywhere is stored in your home directory, /home/ yourusername, and in its subdirectories. This page is asking you where you want to put your code. Click the option, and you’ll be taken to the next page: You can use different Flask versions to the ones we supply by default, but it’s a little more tricky (you need to use a thing called a virtualenv), so for this tutorial we’ll create a site using Python 3.6, with the default Flask version. PythonAnywhere has various versions of Python installed, and each version has its associated version of Flask. ![]() This tutorial is for Flask, so click that one to go on to the next page. This page is where we select the web framework we want to use. This will take you on to the next page in the wizard. If you have a free account, just click the “Next” button, and if you have a paid one, click the checkbox next to the yourusername. Paid accounts have the option of using their own custom host names in their URLs.įor now, we’ll stick to the free option. Free accounts can have one website, and it must be at yourusername. What we’re doing on this page is specifying the host name in the URL that people will enter to see your website. If you decided to go for a paid account (thanks :-), then it will be a bit different: If you have a free account, it will look like this: This will pop up a “Wizard” which allows you to configure your site. Now, click on the “Web” link near the top right, and you’ll be taken to a page where you can create a website:Ĭlick on the “Add a new web app” button to the left. Otherwise if you forget your password later, you won’t be able to reset it. I recommend you check your email and confirm your email address – Now you’re presented with the PythonAnywhere dashboard. You can just click “End tour” here,īecause this tutorial will tell you all you need to know. The tour so that you can learn how the site works – it’ll only take a minute or so.Īt the end of the tour you’ll be presented with some options to “learn more”. Once you’ve signed up, you’ll be taken to the dashboard, with a tour window. A free “Beginner” account is enough for this tutorial. Let’s get started! First steps ¶įirstly, create a PythonAnywhere account if you haven’t already. We assume that you’ve got a little bit of basic Python and HTML knowledge – forĮxample, that you’ve done an online course in both of them. Just a page where anyone can leave a comment, with the comments stored in aĭatabase so that they last forever. It’s really easy to get started with Flask on PythonAnywhere, but if it’s theįirst database-backed website you’ve ever built, it can feel a little daunting. A beginner's guide to building a simple database-backed Flask website on PythonAnywhere ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |