Creating a new project — fantastico 0.1.1-b87 documentation

### Navigation

- index
- next |
- previous |
- fantastico 0.1.1-b87 documentation »
- How to articles »

# Creating a new project

A new Fantastico based project can be easily setup by following this how to. In this how to we are going to create a project named fantastico_first.

1. cd ~/
2. mkdir fantastico_first
3. cd fantastico_first
4. virtualenv-3.2 –distribute pip-deps
5. . pip-deps/bin/activate
6. pip install fantastico
7. fantastico_setup_project.sh python3.2 my_project

The last step might take a while because it will also install all fantastico dependencies (e.g sphinx, sqlalchemy, ...). Please make sure your replace python3.2 with the correct python version. In order to test the current project do the following:

1. fantastico_run_dev_server
2. Access http://localhost:12000/fantastico/samples/mvc/static/sample.jpg
3. Access http://localhost:12000/mvc/hello-world

Your newly project is setup correctly and it runs fantastico default samples project.

## Create first component

After the new project it’s correctly setup we can create our first component.

1. . pip-deps/bin/activate

2. export FANTASTICO_ACTIVE_CONFIG=my_project.settings.BaseProfile

3. cd my_project

4. mkdir component1

5. cd component1

6. mkdir static

7. Paste an image into static folder (e.g first_photo.jpg)

8. touch __init__.py

9. touch hello_world.py

10. Paste the code listed below into hello_world.py

        from fantastico.mvc.base_controller import BaseController
        from fantastico.mvc.controller_decorators import ControllerProvider, Controller
        from webob.response import Response

        @ControllerProvider()
        class HelloWorldController(BaseController):
            '''This is a very simple controller provider.'''

            @Controller(url="/component1/hello")
            def say_hello(self, request):
                '''This method simply returns an html hello world text.'''

                msg = "Hello world from my project"

                return Response(content_type="text/html", text=msg)

11. fantastico_dev_server

12. Now you can access Hello route.

13. Now you can access First photo route.

## Customize dev server

For understanding how to customize dev server please read Development mode

## Customize uwsgi prod server

By design, each Fantastico project provides built in support for running it on uWSGI server. If you want to customize uwsgi parameters for your server you can follow these steps:

1. cd $FANTASTICO_PROJECT_FOLDER/deployment/conf/nginx
2. nano fantastico-uwsgi.ini
3. Change the options you want and save the file.
4. fantastico_run_prod_server (for testing the production server).
5. Be aware that first you need an nginx configured and your project config file deployed (Read Deployment how to).

### Navigation

- index
- next |
- previous |
- fantastico 0.1.1-b87 documentation »
- How to articles »