An Interest In:
Web News this Week
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
November 15, 2022 07:04 am GMT
Original Link: https://dev.to/nitinkumar30/how-to-host-your-flask-app-free-online-c0j
How to host your Flask app free online
So, today we'll learn how to host our flask code online without any charges.
Requirements
[ That's it for free hosting ]
Steps
- Create an account in Python Anywhere
- Click on Web TAB and click on Add a new web app button in the left side
- Click on Next button below
- Select flask from the options below
- Select the latest python version from list
- Edit the file name of your project in the end. I'm editing with mine as app.py
- A new folder with /mysite will be created in our file manager. Click on Files TAB from the navigation bar. Click on the /mysite directory in the left corner.
- If you need to create directory, follow the left corner textbox, write the directory name & click New Directory button.
- Upload the files here.
N.B. - You can't upload multiple files at a time. Also, if there exist any directory, you need to create one & then upload files.
- Once again navigate to Web TAB & click on Reload USERNAME.pythonanywhere.com ; where USERNAME is your username
- That's it. Your site is live now. Let's check mine!
Getting some error? Try some of the below debugging :
- Try to update & install the libraries/modules which may not be installed in your Python Anywhere account.Navigate to the Files TAB & then to the /mysite folder & click on Open bash console here hyperlink.
- Type the following command in console
pip install -r requirements.txt
[ If you have a requirements.txt file]
In case you don't have, check how to create one from here
- All the required dependencies will be installed.
- Now go back to Web TAB & click on Reload USERNAME.pythonanywhere.com ; where USERNAME is your username.
- Another is the config file. We call it as WSGI config file. You could find it in Web TAB only.
- Click on the file name to edit the config file.
- Check all the contents should be like below code:
import sys# add your project directory to the sys.pathproject_home = '/home/name01001/mysite'if project_home not in sys.path: sys.path = [project_home] + sys.path# import flask app but need to call it "application" for WSGI to workfrom app import app as application # noqa
- Click on Save button
- Now go back to Web TAB & click on Reload USERNAME.pythonanywhere.com ; where USERNAME is your username.
I've tried to teach how to host Python (Flask) app for free. However, if you're facing any difficulty, do mention it in the comment. Wil try to help.
You can follow me on LinkedIn, Instagram or check my latest projects on my GitHub. Also, you can check my portfolio too.
[Keep Coding] [Thanks]
Original Link: https://dev.to/nitinkumar30/how-to-host-your-flask-app-free-online-c0j
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To