Python + flask + html/css + mysql + BAE build the CSDN resume Automatic Generation System (with the complete website source code), flaskcsdn

Source: Internet
Author: User

Python + flask + html/css + mysql + BAE build the CSDN resume Automatic Generation System (with the complete website source code), flaskcsdn
1. Background
I always wanted to write a web app for fun. I read a web-app automatically generated by resume on github a few days ago, so I copied a csdn resume generator. The structure is very simple. The front end is an html/css file (this imitates the github webpage because the blogger does not know the front end very well ). The background is a crawler software that crawls the personal information of csdn, displays it, and finally deploys it to Baidu cloud. Baidu's apsaradb is so boring that I have been debugging for a long time and cannot insert data. Now, let's start with the Project address http://resumecsdn.duapp.com /.
(1) start page

(2) generated resume

2. Project Introduction (1) Front-end
The front-end is mainly html and css, which I refer to others' changes. It should be easier for people who have experienced code. The interaction between the front-end and the backend is mainly through setting the method in the html, and then the data can be transmitted in {data}, which is easier, you can understand it at the beginning of the Code.
(2) flask
Flask is a lightweight python web framework. The blogger originally planned to use Douban (the background of Douban was written in python), but found it too difficult to use it. The advantage of flask is that it is straightforward.

@app.route('/')def home():   #mysql_manager.sql_connect()       return render_template('index.html')@app.route('/signup', methods=['POST'])def signup():    #session['username'] = request.form['username']    session['message'] = request.form['message']    return redirect(url_for('message'))
In this case, app.routecan be used to directly renew the webpage. render_template('index.html ') is to open the index page. Its file structure can be shown to you. All html files are stored in the template folder, and css configuration files and databases can be placed in the static folder.
The advantage of this framework is that, the basic look at the example can start to do it, recommend a Website: http://maximebf.com/blog/2012/10/building-websites-in-python-with-flask/

(3) introduce the crawler file, that is, the background crawler file. Because it is disguised as browser browsing, a head is added to avoid some anti-crawler websites. The rest is that using urllib functions with regular matching is easier.
headers = {      'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6'       }     req = urllib2.Request(      url='http://blog.csdn.net/'+name,      headers = headers      )  

(4) deploy to BAE
What does BAE say? mysql has very few functional documents, which makes me very uncomfortable. However, other functions are also possible. The third-party libraries that support many pythons can be defined in requirements.txt. Usage: register an account, and then it will give you a git address and clone it to your local device. Then you can modify it. Of course, you have to push it after the modification, and you have to click "quick release" for each modification ".


Note the following:
1. First, app. conf. Add a star number to the url.
handlers:  - url : /.*    script: __init__.py


2. Add the third library to requirements.txt, so that the bae will automatically help you.
flaskMySQL-python


3. Pay attention to the difference between local debugging and putting it into BAE
Debug and run the program locally in the following statement _ init _. py file. Then you can view the program in the browser.
if __name__ == '__main__':     app.run()


To put it on the BAE, comment out the local debugging statement and add the following in _ init _. py:
from bae.core.wsgi import WSGIApplication  application = WSGIApplication(app)  


4. Pay attention to kill the thread after local debugging. The method is in shell:
lsof -i:5000

Then kill the corresponding ID number.

Just ------------------------- that's enough. If you want to know more about it, you can go to the project to see the github address project demonstration address. If you have a star, it's always my dream to own star100 + projects.


/********************************

* This article is from the blog "Li bogarvin"

* Reprinted please indicate the source: http://blog.csdn.net/buptgshengod

**************************************** **/






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.