how to create a web2py app from command line? - python

I am trying to create a web2py app from command line with -S ... However, I would like to create an app without the "No app, Create one?" question. Is there someway I can create it in a forceful manner.
I have tried app_create() from gluon.admin but there I face the problem of the Request argument. None value for request doesn't seem to work.
Help would really be appreciated. Thanks!

I see Massimo Di Pierro answered your question here.
Although it is not what you asked about, I'd like to add this answer to hopefully help those who come here for a related problem. I.E. how to create a new web2py app WITHOUT browser IDE, in windows?
Notice in the web2py book chapter 4 it says, "The tar gzipped scaffolding app that ship with web2py is welcome.w2p". Therefore:
copy welcome.w2p to mytempdir
rename welcome.w2p welcome.gz
using winzip[gui] or other extract welcome.gz to mytempdir
mytempdir will contain a new file named welcome.w2p
rename welcome.w2p welcome.tar
using winzip[gui] or other extract welcome.tar to mytempdir/appname
copy mytempdir/appname into web2py/applications

Related

Linking python file into functioning HTML/CSS website

I'm giving myself a project to better learn these languages which I already know a lot of it's just syncing them together I need to get better with. This project is a pretty basic "SIM" game, generate some animals into your profile with login/logout. So far I've got the website aspect with HTML/CSS done and functioning with all the pages I currently need all of which is local host on my desktop. Now I'm moving on to working with Python and possibly some PHP aspects into this to get the login/logout and generate a new animal into your account.
Everything I've done with python so far has been done in IDEL, I'm wondering how to link my python document to my HTML document. Like you would CSS? Or is that not possible if not then how do I connect the two to have python interact with the HTML/CSS that has been created? I'm guessing to need MySQL for a database setup but seeing how much I can get as a simple local host without hosting online?
If you want to setup a localhost with PHP and MYSQL I can recommend XAMP (https://www.apachefriends.org/). In order for your webapp to talk to your Python scripts you will either need to use FLASK or Django to create a python webserver, or use PHP to run python scripts. Either way, you will need to make AJAX requests to an API to get this done.
Edit: Forgot to mention this, but you will need JavaScript in order to do this

How can I create a downloadable VrCard on my flask web page?

I would like to create a vcf file on my website that users can download and add the file info to their contacts on their mobile phones.
So far I have made this:
Download
When I click the link it downloads a vcf file. When I open it, it redirects me to my contacts app and throws me this error: "No importable cards were found." That´s because I haven´t set any information in any VCard. I would like to know how can I set/create a VCard with the information I have in my SQLAlchemy database (name, email,phonenumber,website,etc.) Thanks in advance
I had to solve this problem recently for work. Here is how I did it!
The broad strokes: Created a Jinja2 template based on my team's needs for vcard output, a data model to lay over the template, a service to render the template from the database query, and finally, using io.BytesIO and flask.send_file to transmit the data in file format to the user.
The gist linked above doesn't have the more contextual parts of the implementation, but does provide an example of how to wire up flask to do this.
Edit: I evaluated the vobject library that i found recommended, but I honestly didn't think it was intuitive to use or very pythonic, meaning it wasn't something I wanted to depend on in my code base. However, maybe it'll work better for you (or others).

Relative import of a apackage in python flask application

Trying to make the sample flask application more modular,I am new to python and flask trying to build a sample application where , I have planned to maintain the folder structure of the application as shown below
where the description of the package are as fallows
config ---> database configuration details
flaskApp
1 model--->which has the mongodb schema
2 viewController----> the endpoint to be accessed
static--->
which contains the single html page which i just need to serve (not render it)
The code repo for the same is in github
https://github.com/dhanalakshmiZendynamix/python-Flask-relative-module.git
I am facing following problems
1: I am not finding a easy way to access the packages to another packages as in folder structure(ie, models inside viewController where the end points are present)
2:Not sure how to serve the html page inside static folder
Tried reading many source
https://exploreflask.com/en/latest/preface.html
http://pyvideo.org/pycon-us-2014/writing-restful-web-services-with-flask.html
But still not sure how to get it working
Please help to adopt to the above folder structure and access to the end point really not sure how to go about it
Any suggestion and pointer would help a lot Thank you
#dhana lakshmi
Check the registered url endpoints in your app.
Start Python on the commandline in your project directory and execute the following commands:
>>> import flaskApp
>>> app = flaskApp.create_app()
>>> app.url_map
Please add the output to your question
And I really think you need to read up a bit on python and flask first, here is a list with some great resources on flask https://github.com/humiaozuzu/awesome-flask

Setting up a Python ViewServer for CouchDB

I am trying to get up to speed with CouchDB. As a relatively new user on Python, I am trying to set up a view-server so that I can pass on python functions to couchdb.design.ViewDefinitions function. As I understand, ViewDefinitions take javascript code to execute map/reduce function.
Here is what I struggle to understand - I am well aware that this might be a basic question. According to wiki (http://wiki.apache.org/couchdb/View_server):
To register query servers with CouchDB, add a line for each server to local.ini. The basic syntax is:
'[query_servers] python=/usr/bin/couchpy'
How do I access local.ini file? I am an 10.6.8 Mac user. Thanks!
Update: Thank you Kxepal. It seems I was able to create the design/view on Futon in Python. Alternatively, I figured that python viewserver can be created as follows:
curl -X PUT http://[localhost]/_config/query_servers/python '"/path/to/couchpy"'
However, I still cannot execute the python script. Running the view on Couch results in following:
'Error: An error occurred accessing the view no response'
I would appreciate if somebody can point in the right direction. Thanks!
I encountered the same "Error: An error occurred accessing the view no response" problem, and it turned out to be a bug in my python code. Specifically, in the javascript implementation I had something like:
function (doc) {
emit(doc.somefield, doc);
}
I had converted this to:
def map(doc):
yield doc.somefield, doc
However, this gave me the "no response" error you describe.
Changing it to the following fixed the problem.
def map(doc):
yield doc['somefield'], doc
I don't know there OSX keeps CouchDB config files, but you always may setup Python query server through Futon. On sidebar click Configuration, than "Add section" at the bottom of the page and fill the fields with same data as you planned to write into local.ini. As bonus, you don't need restart CouchDB - configuration changes through HTTP API are applied instantly, but be sure that you'd specified correct values.

How to run two projects under single domain?

Hi i want to run two projects under single domain.
Right now only one project is running (means url of first project is running), If i passsed the url of 2nd project then it shows me that url doesn't exist.
I am doing this first time and i don't know what to do ?
So please anybody can tell me how i can done that, and which are the file si have to edit and how.
You can use VirtualHosts to create a subdomain.
http://httpd.apache.org/docs/2.2/vhosts/examples.html
Read:
http://blog.dscpl.com.au/2012/10/requests-running-in-wrong-django.html
and edit your question with the mod_wsgi configuration you are using so can see how you are trying to do it now.

Categories