pythonanywhere

Flask, not all arguments converted during string formatting

十年热恋 提交于 2019-12-06 02:36:55
Try to create a register page for my app. I am using Flask framework and MySQL db from pythonanywhere.com . @app.route('/register/', methods=["GET","POST"]) def register_page(): try: form = RegistrationForm(request.form) if request.method == "POST" and form.validate(): email = form.email.data password = sha256_crypt.encrypt((str(form.password.data))) c, conn = connection() x = c.execute("SELECT * FROM users WHERE email = (%s)", (email)) if int(x) > 0: flash("That email adress is already in use.") return render_template('register.html', form=form) else: c.execute("INSERT INTO users (email,

Restart server from bash console

痴心易碎 提交于 2019-12-06 02:29:12
Is there any way to restart the web server from within the bash console given in the browser for PythonAnywhere ? I have searched google for a while and have not found anything relevant. There is a file for each of your web apps in /var/www . The naming of the file should make it obvious which file applies to which web app. Type touch /var/www/<filename> (where <filename> is the name of the file that is for the web app you want to restart) and server will notice that the modified date of the file has changed and restart your app. As quoted by harry, one of the people working at PythonAnywhere

Using PythonAnywhere as a game server

可紊 提交于 2019-12-06 01:30:14
I'm building a turn-based game and I'm hoping to implement client-server style networking. I really just need to send the position of a couple of objects and some other easily encodable data. I'm pretty new to networking, although I've coded some basic stuff in socket and twisted. Now, though, I need to be able to send the data to a computer that isn't on my local network, and I can't do port forwarding since I don't have admin access to the router and I'm also not totally sure that would do the trick anyways since I've never done it. So, I was thinking of running some Flask or Bottle or

简易博客开发(8)----django1.9 博客部署到pythonanywhere上

别说谁变了你拦得住时间么 提交于 2019-12-06 00:49:43
pythonanywhere只允许用户的一个应用是免费的,但这已经足够做一个博客了,开心之余不免又研究起来,用了一个下午的时间,这个丑陋的博客终于上线了 首先你得注册一个用户 http://pythonanywhere.com 注册完后你可以在account中了解到免费的用户享受到的权利,500M的自主空间,红框就是你的权利 随后你就可以增加一个新的应用,你可以选择语言开发环境 选择python3你才可以用最新的django,而我用的是python2.7,所以一开始纠结,后来看到可以自己搭虚拟环境进行任意搭配,豪不犹豫 选择自己搭建,pythonanywhere有很好的提示,只要按照步骤来就没问题 进到bash下,太熟悉不过了,就是一个linux台主机,之前我们就在centos下面搭的,再搭一次也没问题,但现在是别人的主机,一些规则还是要听的 进行的操作如下 06:50 ~ $ mkvirtualenv django18 #给虚拟主机命名 New python executable in /home/terryding/.virtualenvs/django18/bin/python2.7 Also creating executable in /home/terryding/.virtualenvs/django18/bin/python Installing

web2py git integration - localhost & pythonanywhere

心不动则不痛 提交于 2019-12-05 19:01:38
I have absolutely no idea how to integrate Github into web2py. I have web2py installed on a usb and also on pythonanywhere . The web2py overview document chapter3 http://web2py.com/books/default/chapter/29/03/overview says : Git integration The admin app also includes git integration. Python git libraries are required, e.g. pip install gitpython This doesn't mean a thing to me!!? I am just getting into programming and trying to make sure everything is set up properly! Any help would be really appreciated! Many thanks pip install gitpython is a command to type into a command line. That would be

Issue reading csv file

主宰稳场 提交于 2019-12-05 17:58:55
I am having trouble reading a saved csv with python: import csv with open('blah.csv','rb') as csvfile: data = csv.reader( csvfile ) row_count = sum(1 for row in data) print row_count r = 1 for row in data: print r My issue is that although python seems to recognise the file and recognise that row_count = 9 (and prints this) it doesn't print r for each row in the later loop. This code runs correctly on my computer, but not in the cloud on www.pythonanywhere.com That is because in the following line - row_count = sum(1 for row in data) - you have already read through the file and it has reached

Pythonanywhere install and import new module

a 夏天 提交于 2019-12-05 10:41:01
I'm new to Pythonanywhere and want to install the 'soundcloud' Python module. I've opened up a Bash console and given the pip install --user soundcloud command. It appears to have installed, as I see it in the list of modules when I used pip freeze in the Bash console. However, when I open up a Python 2.7 console and try import soundcloud , I get an error message saying that the Soundcloud module does not exist. Any ideas on why this is happening? You've installed soundcloud for 2.6, but you're trying to use it in 2.7. From the FAQ : We've included both easy_install and pip for Python versions

Change Timezone for Date object Python

 ̄綄美尐妖づ 提交于 2019-12-05 10:28:41
Hello I am using Pythonanywhere and when I call from datetime import * print date.today().day It is printing a different day than the day it is where I live (Austin, Texas). I figured it is because there is a timezone difference. How would I tell the date object where I live so it gets the right timezone. Thanks in advance The most robust way to do this is to use pytz . You can install it simply with pip install pytz . To get the local date with pytz , you can simply do this (note that the date.today method will not take a timezone): >>> from datetime import datetime >>> import pytz >>> local

Converting docx to pdf with pure python (on linux, without libreoffice)

烂漫一生 提交于 2019-12-04 17:23:30
问题 I'm dealing with a problem trying to develop a web-app, part of which converts uploaded docx files to pdf files (after some processing). With python-docx and other methods, I do not require a windows machine with word installed, or even libreoffice on linux, for most of the processing (my web server is pythonanywhere - linux but without libreoffice and without sudo or apt install permissions). But converting to pdf seems to require one of those. From exploring questions here and elsewhere,

Converting docx to pdf with pure python (on linux, without libreoffice)

自闭症网瘾萝莉.ら 提交于 2019-12-03 10:24:07
I'm dealing with a problem trying to develop a web-app, part of which converts uploaded docx files to pdf files (after some processing). With python-docx and other methods, I do not require a windows machine with word installed, or even libreoffice on linux, for most of the processing (my web server is pythonanywhere - linux but without libreoffice and without sudo or apt install permissions). But converting to pdf seems to require one of those. From exploring questions here and elsewhere, this is what I have so far: import subprocess try: from comtypes import client except ImportError: client