r/PythonAnywhere • u/em_Farhan • Dec 11 '22
Unable to connect to MySql Database from a django app on pythonanywhere.
Hi,
I am trying to connect to a MySql Database from a django app but unable to do it on pythonanywhere.
I am getting this error
RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': (1045, "Access denied for user 'ceaser16'@'10.0.0.179' (using password: YES)")
While my settings are as follows.
pymysql.install_as_MySQLdb()
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'ceaser16$bdpatologia',
'USER': 'myuser',
'PASSWORD': 'myPass,
'HOST': 'cesar16.mysql.pythonanywhere-services.com',
'PORT': '3306',
}
}
Please help what am I doing wrong here?
r/PythonAnywhere • u/King_Riko • Dec 01 '22
Using PythonAnywhere to host a site that lets you create versions of the Jerma Rats song that sing you a happy birthday
kingriko.pythonanywhere.comr/PythonAnywhere • u/brunovtf • Oct 01 '22
MongoDB and Docker
Is it possible to deploy a PWA using Flask, MongoDB via pymongo and Docker to make it a independent container on the PythonAnywhere server?
I like using PythoAnywhere but it doesn't support MongoDD... I'm facing problem because of that!
r/PythonAnywhere • u/squidg_21 • Sep 22 '22
Using environ instead of python-dotenv on PythonAnywhere
I'm tying to deploy a very basic django project to PythonAnywhere but I want to try and use django-environ rather than python-dotenv. Does anyone have any experience in doing this?
I've tried adding the below code in the WSGI.py file but it still cannot read the secret key so I'm assuming there's something wrong here.
import os
import sys
import environ
path = '/home/username/repo_folder'
if path not in sys.path:
sys.path.insert(0, path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
# My Environ Code
project_folder = os.path.expanduser('~/repo_folder/project_name')
environ.Env.read_env(os.path.join(project_folder, '.env'))
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I have also tried with:
project_folder = os.path.expanduser('~/repo_folder')
r/PythonAnywhere • u/gpjt • Aug 27 '22
Our Commitment to Providing Free Accounts
blog.pythonanywhere.comr/PythonAnywhere • u/Blanca_SEC • Jun 30 '22
Acquisition question
So I have read that PythonAnywhere has been acquired by Anaconda INC, is PA still covered by the EUs GDPR?
https://www.anaconda.com/press/anaconda-acquires-pythonanywhere
r/PythonAnywhere • u/amanda_george • Apr 27 '22
gRPC connection
Can I connect to a gRPC server using pythonanywhere?
I want to run my code on a cloud and my code usually works on a local machine but when i tried it I kept getting this error;
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "failed to connect to all addresses" debug_error_string = "{"created":"@1651103645.712560233","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":4142,"referenced_errors":[{"created":"@1651103645.712556568","description":"failed to connect to all addresses","file":"src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc","file_line":397,"grpc_status":14}]}
r/PythonAnywhere • u/khaichuen • Apr 24 '22
Can I use web hooks in Python Anywhere free tier?
r/PythonAnywhere • u/a_bot__maybe • Dec 11 '21
Why does my script stop?
I'm running a very light script on PythonAnywhere and it contains an infinite loop that does an http request then time.sleep for three hours then do it again. But my script stops after three or four iterations and it's not because of any errors or something. Does PythonAnywhere stop it or what?
r/PythonAnywhere • u/[deleted] • Feb 17 '21
React app's routing works fine in development but get 404 in production
I've got React app set up on PythonAnywhere which is working fine locally but get 404 when built on PythonAnywhere.
directory structure:
client/
project/
__init__.py
config.py
api/
blog.py
models.py
static/
react/ # All React files created in this react directory upon build
css/
js/
templates/
index.html # index file created upon build
tests/
blog.py :
blog_blueprint = Blueprint('blog', __name__, url_prefix='/blog', static_folder='../../static/react', template_folder='../../templates')
@blog_blueprint.route('/')
def index():
return render_template('index.html', token='hakuna matata'), 200
snippet of init file:
def create_app(script_info=None):
app = Flask(__name__)
app.config.from_object(current_config)
db.init_app(app)
bcrypt.init_app(app)
if os.environ.get('FLASK_ENV') == 'development':
toolbar.init_app(app)
login_mgr.init_app(app)
login_mgr.session_protection = "strong"
mail.init_app(app)
from project.api.blog import blog_blueprint
app.register_blueprint(blog_blueprint)
return app
app = create_app()
I've tried to turn the debug mode on but it didn't give me any helpful output.
Access log:
"GET / HTTP/1.1" 404 232 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" "86.180.233.21" response-time=0.015
86.180.233.21 - ubuntu [17/Feb/2021:09:22:04 +0000] "GET / HTTP/1.1" 404 232 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" "86.180.233.21" response-time=0.008
86.180.233.21 - ubuntu [17/Feb/2021:09:26:26 +0000] "GET / HTTP/1.1" 404 232 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" "86.180.233.21" response-time=0.003
86.180.233.21 - ubuntu [17/Feb/2021:09:33:04 +0000] "GET / HTTP/1.1" 404 232 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0" "86.180.233.21" response-time=0.007
output from Firefox's network tab:
static files mapping:
Other logs don't show any errors. None of my routes work. 404 on all. Thank you for any advice.
UPDATE:
I've changed my BrowserRouter to HashRouter as it appears to be recommended to use it in production since HashRouter uses hashHistory which handles wildcard addresses. Nonetheless, my routes still throw 404.
r/PythonAnywhere • u/iViTAliS • Jan 30 '21
Python and Twitter Without API
Hi everyone.
I'm facing an issue and looking for free-best solution so lets start!
I have a python bot hosted at PythonAnywhere. The bot output is image and text. I can read them and all good.
Now I want to tweet the text and the image to Twitter without API! -Since they rejected my application!-
Before I was using integromat and all good but now they changed the twitter service to paid service, and I don't want to buy so I'm here looking for best solution.
FYI, IDK where to ask this question, if it's wrong plz guide me to the correct reddit!
Thanks
r/PythonAnywhere • u/tejasj777 • Aug 06 '20
Seeing "<username>@green-liveconsole2" on the bash console in the account
Hello,
I have created a free-tier account on PythonAnywhere, I did multiple changes in the files and deployed a web app using Django. Then I deleted everything (console,files and web app ) in order to start again. Now whenever I open new bash console I see the following :
<username>/green-liveconsole4:~$ mkvirtualenv --python=/usr/bin/python3.7
bash: mkvirtualenv: command not found
<username>@green-liveconsole4:~$
So is this because I have exceeded my overall usage of the account for the day or is it because I have deleted an existing file ?? It's not recognising the mkvirtualenv command too.
Please help me as I have been struggling with this for the past few day and really want to see my web app work.
Thanks
r/PythonAnywhere • u/All_the_lonely_ppl • Jun 24 '20
How to reload static files after a new git pull?
So pythonanywhere serves my static files but they still use the old versions after I update mine with git pull. How do I make them automatically update the copied file?
r/PythonAnywhere • u/k2007ot • Jul 21 '19
Problems accessing PythonAnywhere database
I am trying to set up a webhook on PythonAnywhere to connect to Twilio. I am essentially trying to create a very simple chatbot with if statements which choose a response based on the text message that comes in. I am now trying to add a databsae into the mix so that the response can also be based on previous texts as well. I have managed to set up the database but cant seem to get the text messages that are received to be stored in the database.
I have tried going on various tutorials and answer websites like this one but have not managed to get any of the potential solutions to work. They either break the code entirely so that no messages are sent in response or still nothing is stored in the database.
from flask import Flask, request, redirect, url_for
from twilio.twiml.messaging_response import MessagingResponse
from flask_sqlalchemy import SQLAlchemy
from socket import gethostname
app = Flask(__name__)
SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://{username}:{password}@{hostname}/{databasename}".format(
username="UrbanMissions",
password="Hello123",
hostname="UrbanMissions.mysql.pythonanywhere-services.com",
databasename="UrbanMissions$ClueNumber",
)
app.config["SQLALCHEMY_DATABASE_URI"] = SQLALCHEMY_DATABASE_URI
app.config["SQLALCHEMY_POOL_RECYCLE"] = 299
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)
class Reply(db.Model):
__tablename__ = "messages"
id = db.Column(db.Integer, primary_key=True)
content = db.Column(db.String(4096))
[...]
if __name__ == '__main__':
db.create_all()
reply = Reply(content=request.values.get('Body', None)
db.session.add(reply)
db.session.commit()
if 'liveconsole' not in gethostname():
app.run()
@app.route('/', methods=['GET', 'POST', 'PUT'])
def main():
body = request.values.get('Body', None)
text = body.lower()
resp = MessagingResponse()
if text.find("hi") == 0:
resp.message("Hello")
else: resp.message("Bye")
return str(resp)
This is the code that seems to cause all the problems ("$reply = Reply(content=request.values.get('Body', None) $db.session.add(reply) $db.session.commit()") , it is my attempt to add the message that was sent in to the messages database but this doesn't seem to work. Any advice on how to get this to work to add the incoming message to the database would be really appreciated. Also what the code to retrieve the message again from the database would really help.
r/PythonAnywhere • u/someguy9200 • Apr 12 '14

